3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class base { function __construct() {} function init() { echo 'Base class (__CLASS__): ' . __CLASS__ . PHP_EOL; echo 'Base class (get_class()): ' . get_class($this) . PHP_EOL; echo PHP_EOL; } } class derived extends base { function init2() { echo 'Derived class (__CLASS__): ' . __CLASS__ . PHP_EOL; echo 'Derived class (get_class()): ' . get_class($this) . PHP_EOL; echo PHP_EOL; } function init3() { parent::init(); } } $a = new derived(); $a->init(); $a->init2(); $a->init3();
Output for 5.0.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Base class (__CLASS__): base Base class (get_class()): derived Derived class (__CLASS__): derived Derived class (get_class()): derived Base class (__CLASS__): base Base class (get_class()): derived
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 6 Base class (__CLASS__): basePHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 7 Base class (get_class()): derivedPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 8 PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 14 Derived class (__CLASS__): derivedPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 15 Derived class (get_class()): derivedPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 16 PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 6 Base class (__CLASS__): basePHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 7 Base class (get_class()): derivedPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/4pDnO on line 8 PHP_EOL
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/4pDnO on line 2
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/4pDnO on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/4pDnO on line 2
Process exited with code 255.