3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php unset($this); class Foo{ private static $this; protected $a = true; public function __construct(){ self::$this = new Foo(func_get_args()); echo "From Foo()"; } public static function init(){ //var_dump(new Foo); var_dump(self::$this->test()); echo "From Foo::init()"; } public function test(){ echo "called from static"; } } Foo::init();
based on NOXFM
Output for 7.1.0
Fatal error: Cannot unset $this in /in/gabXB on line 2
Process exited with code 255.
Output for 7.0.0 - 7.0.14
Fatal error: Uncaught Error: Call to a member function test() on null in /in/gabXB:12 Stack trace: #0 /in/gabXB(19): Foo::init() #1 {main} thrown in /in/gabXB on line 12
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Call to a member function test() on null in /in/gabXB on line 12
Process exited with code 255.
Output for 5.4.22 - 5.5.35
Fatal error: Call to a member function test() on a non-object in /in/gabXB on line 12
Process exited with code 255.
Output for 5.0.0 - 5.4.21
Fatal error: Cannot re-assign $this in /in/gabXB on line 7
Process exited with code 255.
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/gabXB 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/gabXB 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/gabXB on line 4
Process exited with code 255.