3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { $elements = array(); function Foo() { $stdObj = new stdClass; $stdObj->name = 'foo1'; $stdObj->active = false; $this->elements[] = $stdObj; } function getElementByName($name) { foreach($this->elements as $elm) { if ($elm->name == $name) { return $elm; } } } function test( ){ return $this->elements; } } $myFoo = new Foo(); $myFoo->getElementByName('foo1')->active = true; var_dump($myFoo->test());
Output for 5.4.0 - 5.4.20
Parse error: syntax error, unexpected '$elements' (T_VARIABLE), expecting function (T_FUNCTION) in /in/HKsTl on line 7
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /in/HKsTl on line 7
Process exited with code 255.

preferences:
176.88 ms | 1395 KiB | 56 Q