3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class String { private $_stringValue; public function __construct($stringValue = '') { $this->_stringValue = ''.$stringValue; } public function __toString() { return $this->_stringValue; } public function getLength() { return mb_strlen($this->_stringValue); } } abstract class AbsTestClass { protected $_privateProperty = 'World'; public function __construct($name) { $this->_privateProperty = $name; } public function getName() { return $this->_privateProperty; } public function getWelcomingMessage() { return 'Hello '.$this->getName().'!'; } abstract public function setName(String $name); } class TestClass extends AbsTestClass { public function setName(String $name) { $this->_privateProperty = $name->__toString(); } } $message = new TestClass('World'); echo $message->getWelcomingMessage()."\n"; $names = array_fill(0, 300, 'World in Fire'); foreach ($names as $id => $name) { $message->setName(new String("($id) $name")); echo $message->getWelcomingMessage()."\n"; } $message->setName(new String('Jahala')); echo $message->getWelcomingMessage()."\n";
Output for 5.0.0 - 5.6.28
Hello World! Hello (0) World in Fire! Hello (1) World in Fire! Hello (2) World in Fire! Hello (3) World in Fire! Hello (4) World in Fire! Hello (5) World in Fire! Hello (6) World in Fire! Hello (7) World in Fire! Hello (8) World in Fire! Hello (9) World in Fire! Hello (10) World in Fire! Hello (11) World in Fire! Hello (12) World in Fire! Hello (13) World in Fire! Hello (14) World in Fire! Hello (15) World in Fire! Hello (16) World in Fire! Hello (17) World in Fire! Hello (18) World in Fire! Hello (19) World in Fire! Hello (20) World in Fire! Hello (21) World in Fire! Hello (22) World in Fire! Hello (23) World in Fire! Hello (24) World in Fire! Hello (25) World in Fire! Hello (26) World in Fire! Hello (27) World in Fire! Hello (28) World in Fire! Hello (29) World in Fire! Hello (30) World in Fire! Hello (31) World in Fire! Hello (32) World in Fire! Hello (33) World in Fire! Hello (34) World in Fire! Hello (35) World in Fire! Hello (36) World in Fire! Hello (37) World in Fire! Hello (38) World in Fire! Hello (39) World in Fire! Hello (40) World in Fire! Hello (41) World in Fire! Hello (42) World in Fire! Hello (43) World in Fire! Hello (44) World in Fire! Hello (45) World in Fire! Hello (46) World in Fire! Hello (47) World in Fire! Hello (48) World in Fire! Hello (49) World in Fire! Hello (50) World in Fire! Hello (51) World in Fire! Hello (52) World in Fire! Hello (53) World in Fire! Hello (54) World in Fire! Hello (55) World in Fire! Hello (56) World in Fire! Hello (57) World in Fire! Hello (58) World in Fire! Hello (59) World in Fire! Hello (60) World in Fire! Hello (61) World in Fire! Hello (62) World in Fire! Hello (63) World in Fire! Hello (64) World in Fire! Hello (65) World in Fire! Hello (66) World in Fire! Hello (67) World in Fire! Hello (68) World in Fire! Hello (69) World in Fire! Hello (70) World in Fire! Hello (71) World in Fire! Hello (72) World in Fire! Hello (73) World in Fire! Hello (74) World in Fire! Hello (75) World in Fire! Hello (76) World in Fire! Hello (77) World in Fire! Hello (78) World in Fire! Hello (79) World in Fire! Hello (80) World in Fire! Hello (81) World in Fire! Hello (82) World in Fire! Hello (83) World in Fire! Hello (84) World in Fire! Hello (85) World in Fire! Hello (86) World in Fire! Hello (87) World in Fire! Hello (88) World in Fire! Hello (89) World in Fire! Hello (90) World in Fire! Hello (91) World in Fire! Hello (92) World in Fire! Hello (93) World in Fire! Hello (94) World in Fire! Hello (95) World in Fire! Hello (96) World in Fire! Hello (97) World in Fire! Hello (98) World in Fire! Hello (99) World in Fire! Hello (100) World in Fire! Hello (101) World in Fire! Hello (102) World in Fire! Hello (103) World in Fire! Hello (104) World in Fire! Hello (105) World in Fire! Hello (106) World in Fire! Hello (107) World in Fire! Hello (108) World in Fire! Hello (109) World in Fire! Hello (110) World in Fire! Hello (111) World in Fire! Hello (112) World in Fire! Hello (113) World in Fire! Hello (114) World in Fire! Hello (115) World in Fire! Hello (116) World in Fire! Hello (117) World in Fire! Hello (118) World in Fire! Hello (119) World in Fire! Hello (120) World in Fire! Hello (121) World in Fire! Hello (122) World in Fire! Hello (123) World in Fire! Hello (124) World in Fire! Hello (125) World in Fire! Hello (126) World in Fire! Hello (127) World in Fire! Hello (128) World in Fire! Hello (129) World in Fire! Hello (130) World in Fire! Hello (131) World in Fire! Hello (132) World in Fire! Hello (133) World in Fire! Hello (134) World in Fire! Hello (135) World in Fire! Hello (136) World in Fire! Hello (137) World in Fire! Hello (138) World in Fire! Hello (139) World in Fire! Hello (140) World in Fire! Hello (141) World in Fire! Hello (142) World in Fire! Hello (143) World in Fire! Hello (144) World in Fire! Hello (145) World in Fire! Hello (146) World in Fire! Hello (147) World in Fire! Hello (148) World in Fire! Hello (149) World in Fire! Hello (150) World in Fire! Hello (151) World in Fire! Hello (152) World in Fire! Hello (153) World in Fire! Hello (154) World in Fire! Hello (155) World in Fire! Hello (156) World in Fire! Hello (157) World in Fire! Hello (158) World in Fire! Hello (159) World in Fire! Hello (160) World in Fire! Hello (161) World in Fire! Hello (162) World in Fire! Hello (163) World in Fire! Hello (164) World in Fire! Hello (165) World in Fire! Hello (166) World in Fire! Hello (167) World in Fire! Hello (168) World in Fire! Hello (169) World in Fire! Hello (170) World in Fire! Hello (171) World in Fire! Hello (172) World in Fire! Hello (173) World in Fire! Hello (174) World in Fire! Hello (175) World in Fire! Hello (176) World in Fire! Hello (177) World in Fire! Hello (178) World in Fire! Hello (179) World in Fire! Hello (180) World in Fire! Hello (181) World in Fire! Hello (182) World in Fire! Hello (183) World in Fire! Hello (184) World in Fire! Hello (185) World in Fire! Hello (186) World in Fire! Hello (187) World in Fire! Hello (188) World in Fire! Hello (189) World in Fire! Hello (190) World in Fire! Hello (191) World in Fire! Hello (192) World in Fire! Hello (193) World in Fire! Hello (194) World in Fire! Hello (195) World in Fire! Hello (196) World in Fire! Hello (197) World in Fire! Hello (198) World in Fire! Hello (199) World in Fire! Hello (200) World in Fire! Hello (201) World in Fire! Hello (202) World in Fire! Hello (203) World in Fire! Hello (204) World in Fire! Hello (205) World in Fire! Hello (206) World in Fire! Hello (207) World in Fire! Hello (208) World in Fire! Hello (209) World in Fire! Hello (210) World in Fire! Hello (211) World in Fire! Hello (212) World in Fire! Hello (213) World in Fire! Hello (214) World in Fire! Hello (215) World in Fire! Hello (216) World in Fire! Hello (217) World in Fire! Hello (218) World in Fire! Hello (219) World in Fire! Hello (220) World in Fire! Hello (221) World in Fire! Hello (222) World in Fire! Hello (223) World in Fire! Hello (224) World in Fire! Hello (225) World in Fire! Hello (226) World in Fire! Hello (227) World in Fire! Hello (228) World in Fire! Hello (229) World in Fire! Hello (230) World in Fire! Hello (231) World in Fire! Hello (232) World in Fire! Hello (233) World in Fire! Hello (234) World in Fire! Hello (235) World in Fire! Hello (236) World in Fire! Hello (237) World in Fire! Hello (238) World in Fire! Hello (239) World in Fire! Hello (240) World in Fire! Hello (241) World in Fire! Hello (242) World in Fire! Hello (243) World in Fire! Hello (244) World in Fire! Hello (245) World in Fire! Hello (246) World in Fire! Hello (247) World in Fire! Hello (248) World in Fire! Hello (249) World in Fire! Hello (250) World in Fire! Hello (251) World in Fire! Hello (252) World in Fire! Hello (253) World in Fire! Hello (254) World in Fire! Hello (255) World in Fire! Hello (256) World in Fire! Hello (257) World in Fire! Hello (258) World in Fire! Hello (259) World in Fire! Hello (260) World in Fire! Hello (261) World in Fire! Hello (262) World in Fire! Hello (263) World in Fire! Hello (264) World in Fire! Hello (265) World in Fire! Hello (266) World in Fire! Hello (267) World in Fire! Hello (268) World in Fire! Hello (269) World in Fire! Hello (270) World in Fire! Hello (271) World in Fire! Hello (272) World in Fire! Hello (273) World in Fire! Hello (274) World in Fire! Hello (275) World in Fire! Hello (276) World in Fire! Hello (277) World in Fire! Hello (278) World in Fire! Hello (279) World in Fire! Hello (280) World in Fire! Hello (281) World in Fire! Hello (282) World in Fire! Hello (283) World in Fire! Hello (284) World in Fire! Hello (285) World in Fire! Hello (286) World in Fire! Hello (287) World in Fire! Hello (288) World in Fire! Hello (289) World in Fire! Hello (290) World in Fire! Hello (291) World in Fire! Hello (292) World in Fire! Hello (293) World in Fire! Hello (294) World in Fire! Hello (295) World in Fire! Hello (296) World in Fire! Hello (297) World in Fire! Hello (298) World in Fire! Hello (299) World in Fire! Hello Jahala!
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/NlCcD on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/NlCcD on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/NlCcD on line 4
Process exited with code 255.