3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { private $baz = 1; public static function foo() { echo "foo\n"; } public function bar() { echo "bar\n"; $this->foo(); $this::foo(); self::foo(); static::foo(); parent::foo(); self::baz(); } public function baz() { printf("baz = %d\n", $this->baz); } } $test = new Test; $test->bar();
based on GefjH
Output for 7.0.0 - 7.2.0
bar foo foo foo foo Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/W9tHo:19 Stack trace: #0 /in/W9tHo(30): Test->bar() #1 {main} thrown in /in/W9tHo on line 19
Process exited with code 255.
Output for 5.3.18 - 5.6.28
bar foo foo foo foo Fatal error: Cannot access parent:: when current class scope has no parent in /in/W9tHo on line 19
Process exited with code 255.