3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class EmptyObj{ protected function __construct(){} public static function get(){ static $obj; if(!$obj) $obj = new EmptyObj; return $obj; } public function __call($n, $a){ return $this; } public __toString(){ return ''; } } class SomeClass{ public $image; public function __construct(){ $this->image = EmptyObj::get(); }} $a = new SomeClass; echo $a->image->oopsForgotToSetImage();
Output for 5.4.0 - 5.4.13
Parse error: syntax error, unexpected '__toString' (T_STRING), expecting variable (T_VARIABLE) in /in/4rYiR on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.23
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/4rYiR on line 13
Process exited with code 255.