3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class A { protected $a = 'AAA'; private $b = 'BBB'; public function printB() { echo $this->b.PHP_EOL; } } class B extends A { public function printB2() { echo $this->b.PHP_EOL; } public function printA() { echo $this->a.PHP_EOL; } } $obj = new B; $a->printA(); $a->printB(); $a->printB2();
Output for 7.0.5 - 7.1.0
Notice: Undefined variable: a in /in/6Y5ah on line 16 Fatal error: Uncaught Error: Call to a member function printA() on null in /in/6Y5ah:16 Stack trace: #0 {main} thrown in /in/6Y5ah on line 16
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: a in /in/6Y5ah on line 16 Fatal error: Uncaught Error: Call to a member function printA() on unknown in /in/6Y5ah:16 Stack trace: #0 {main} thrown in /in/6Y5ah on line 16
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Notice: Undefined variable: a in /in/6Y5ah on line 16 Fatal error: Call to a member function printA() on null in /in/6Y5ah on line 16
Process exited with code 255.
Output for 5.0.4 - 5.5.35
Notice: Undefined variable: a in /in/6Y5ah on line 16 Fatal error: Call to a member function printA() on a non-object in /in/6Y5ah on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: a in /in/6Y5ah on line 16 Fatal error: Call to a member function printA() on a non-object in /in/6Y5ah on line 16
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/6Y5ah on line 3
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_CLASS in /in/6Y5ah on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/6Y5ah on line 3
Process exited with code 255.