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; $obj->printA(); $obj->printB(); $obj->printB2();
based on 6Y5ah
Output for 5.2.6 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
AAA BBB Notice: Undefined property: B::$b in /in/gA92u on line 11
Output for 5.0.2 - 5.2.5
AAA BBB Notice: Undefined property: B::$b in /in/gA92u on line 11
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/gA92u on line 12 AAAPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/gA92u on line 7 BBBPHP_EOL Notice: Undefined property: B::$b in /in/gA92u on line 11 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/gA92u on line 11 PHP_EOL
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/gA92u 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/gA92u on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/gA92u on line 3
Process exited with code 255.