3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyClass { private static $instance = null; private $my_value = 'Foo'; public function __construct() { } public static function my_function() { if ( ! isSet(self::$instance)) self::$instance = new self; if(isSet($this)) $target = $this; else $target = self::$instance; } return $target->my_value; } } $my_object = new MyClass(); echo $my_object->my_function()."\n"; echo MyClass::my_function();
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected 'return' (T_RETURN), expecting function (T_FUNCTION) in /in/1Ab9X on line 20
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_RETURN, expecting T_FUNCTION in /in/1Ab9X on line 20
Process exited with code 255.