3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public $a; protected $b; private $c; public function __construct() { $this->a = 'A_a'; $this->b = 'A_b'; $this->c = 'A_c'; } } class B extends A { protected $b; private $c; public function __construct($b, $c) { parent::__construct(); $this->b = 'B_b'; $this->c = 'B_c'; } } $b = new B; var_dump($b); $array = (array) $b; var_dump($array);
Output for 7.1.0 - 7.3.0rc3
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::__construct(), 0 passed in /in/8QUGK on line 31 and exactly 2 expected in /in/8QUGK:22 Stack trace: #0 /in/8QUGK(31): B->__construct() #1 {main} thrown in /in/8QUGK on line 22
Process exited with code 255.
Output for 5.6.30, 7.0.0 - 7.0.31
Warning: Missing argument 1 for B::__construct(), called in /in/8QUGK on line 31 and defined in /in/8QUGK on line 22 Warning: Missing argument 2 for B::__construct(), called in /in/8QUGK on line 31 and defined in /in/8QUGK on line 22 object(B)#1 (4) { ["b":protected]=> string(3) "B_b" ["c":"B":private]=> string(3) "B_c" ["a"]=> string(3) "A_a" ["c":"A":private]=> string(3) "A_c" } array(4) { ["*b"]=> string(3) "B_b" ["Bc"]=> string(3) "B_c" ["a"]=> string(3) "A_a" ["Ac"]=> string(3) "A_c" }
Output for hhvm-3.22.0
Warning: __construct() expects exactly 2 parameters, 0 given in /in/8QUGK on line -1 object(B)#1 (4) { ["b":protected]=> string(3) "B_b" ["c":"B":private]=> string(3) "B_c" ["a"]=> string(3) "A_a" ["c":"A":private]=> string(3) "A_c" } array(4) { ["*b"]=> string(3) "B_b" ["Bc"]=> string(3) "B_c" ["a"]=> string(3) "A_a" ["Ac"]=> string(3) "A_c" }
Output for hhvm-3.15.4 - 3.21.3
Warning: __construct() expects exactly 2 parameters, 0 given in /in/8QUGK on line 24 object(B)#1 (4) { ["b":protected]=> string(3) "B_b" ["c":"B":private]=> string(3) "B_c" ["a"]=> string(3) "A_a" ["c":"A":private]=> string(3) "A_c" } array(4) { ["*b"]=> string(3) "B_b" ["Bc"]=> string(3) "B_c" ["a"]=> string(3) "A_a" ["Ac"]=> string(3) "A_c" }