3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php <?php class A { const XXX = 'aaa'; public function P() { return [ 'self' => self::XXX, 'static' => static::XXX, ]; } } class B extends A { const XXX = 'bbb'; public function P2() { return [ 'self' => self::XXX, 'static' => static::XXX, 'parent' => parent::XXX, ]; } } $a = new A(); $b = new B(); var_dump($a->P()); /* array(2) { [0] => string(3) "aaa" [1] => string(3) "aaa" } */ var_dump($b->P()); /* array(2) { [0] => string(3) "aaa" [1] => string(3) "bbb" } */ var_dump($b->P2()); /* array(3) { [0] => string(3) "bbb" [1] => string(3) "bbb" [2] => string(3) "aaa" } */
Output for 7.0.0
Parse error: syntax error, unexpected '<', expecting end of file in /in/aqbBe on line 3
Process exited with code 255.
Output for 5.3.20 - 5.6.16
Parse error: syntax error, unexpected '<' in /in/aqbBe on line 3
Process exited with code 255.