3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class Human { const NAME = 'abstract'; public function getName() { return static::NAME; } } class John extends Human { const NAME = 'John'; } class Mark extends John { const NAME = 'Mark'; } $mark = new Mark(); $johh = new John(); echo $mark->getName(); echo "\n"; echo $john->getName();
based on 78ZZ0
Output for 7.0.5 - 7.2.0
Mark Notice: Undefined variable: john in /in/BLQZA on line 24 Fatal error: Uncaught Error: Call to a member function getName() on null in /in/BLQZA:24 Stack trace: #0 {main} thrown in /in/BLQZA on line 24
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Mark Notice: Undefined variable: john in /in/BLQZA on line 24 Fatal error: Uncaught Error: Call to a member function getName() on unknown in /in/BLQZA:24 Stack trace: #0 {main} thrown in /in/BLQZA on line 24
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Mark Notice: Undefined variable: john in /in/BLQZA on line 24 Fatal error: Call to a member function getName() on null in /in/BLQZA on line 24
Process exited with code 255.
Output for 5.3.21 - 5.5.35
Mark Notice: Undefined variable: john in /in/BLQZA on line 24 Fatal error: Call to a member function getName() on a non-object in /in/BLQZA on line 24
Process exited with code 255.