3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class x extends arrayobject{ protected $a = 'protected'; public $b = 'public'; public function __construct(){ parent::__construct(['a'=>'A', 'b'=>'B'], ARRAY_AS_PROPS); } } $a = new x; echo $a->b; echo $a->a;
Output for 7.2.0
Warning: Use of undefined constant ARRAY_AS_PROPS - assumed 'ARRAY_AS_PROPS' (this will throw an Error in a future version of PHP) in /in/D61YI on line 7 Fatal error: Uncaught TypeError: ArrayObject::__construct() expects parameter 2 to be integer, string given in /in/D61YI:7 Stack trace: #0 /in/D61YI(7): ArrayObject->__construct(Array, 'ARRAY_AS_PROPS') #1 /in/D61YI(11): x->__construct() #2 {main} thrown in /in/D61YI on line 7
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant ARRAY_AS_PROPS - assumed 'ARRAY_AS_PROPS' in /in/D61YI on line 7 Fatal error: Uncaught TypeError: ArrayObject::__construct() expects parameter 2 to be integer, string given in /in/D61YI:7 Stack trace: #0 /in/D61YI(7): ArrayObject->__construct(Array, 'ARRAY_AS_PROPS') #1 /in/D61YI(11): x->__construct() #2 {main} thrown in /in/D61YI on line 7
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Notice: Use of undefined constant ARRAY_AS_PROPS - assumed 'ARRAY_AS_PROPS' in /in/D61YI on line 7 Fatal error: Uncaught exception 'InvalidArgumentException' with message 'ArrayObject::__construct() expects parameter 2 to be long, string given' in /in/D61YI:7 Stack trace: #0 /in/D61YI(7): ArrayObject->__construct(Array, 'ARRAY_AS_PROPS') #1 /in/D61YI(11): x->__construct() #2 {main} thrown in /in/D61YI on line 7
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/D61YI on line 7
Process exited with code 255.