3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public $a; public function __construct($a) { $this->a = $a; } } class B extends A { public $b; public function __construct($b) { $this->b = $b; } public function callParentCtor($args) { call_user_func_array(array(parent, '__construct'), $args); } } $b = new B('b'); $b->callParentCtor([ 'a' ]); var_dump($b);
Output for 7.2.0
Warning: Use of undefined constant parent - assumed 'parent' (this will throw an Error in a future version of PHP) in /in/hGrJo on line 24 object(B)#1 (2) { ["b"]=> string(1) "b" ["a"]=> string(1) "a" }
Output for 5.4.11 - 7.1.10
Notice: Use of undefined constant parent - assumed 'parent' in /in/hGrJo on line 24 object(B)#1 (2) { ["b"]=> string(1) "b" ["a"]=> string(1) "a" }
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/hGrJo on line 29
Process exited with code 255.