3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A extends ArrayObject { public $public; private $private; protected $protected; public function __construct ($input = array()) { parent::__construct($input, ArrayObject::ARRAY_AS_PROPS); } } class B extends ArrayObject { public $public; private $private; protected $protected; public function __construct ($input = array()) { } } class C extends ArrayObject { public $public; private $private; protected $protected; public function __construct ($input = array()) { parent::__construct($input, ArrayObject::STD_PROP_LIST); } } $input = array('public' => 'test', 'private' => 'test', 'protected' => 'test'); $os = array( 'a' => new A($input), 'b' => new B($input), 'c' => new C($input), ); foreach($os as $n => $o) { echo str_repeat('=', 60), "\n"; echo "$n\n"; var_dump($o); var_dump($o->public); echo "\n"; echo str_repeat('=', 60), "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
============================================================ a object(A)#1 (4) { ["public"]=> NULL ["private":"A":private]=> NULL ["protected":protected]=> NULL ["storage":"ArrayObject":private]=> array(3) { ["public"]=> string(4) "test" ["private"]=> string(4) "test" ["protected"]=> string(4) "test" } } NULL ============================================================ ============================================================ b object(B)#2 (4) { ["public"]=> NULL ["private":"B":private]=> NULL ["protected":protected]=> NULL ["storage":"ArrayObject":private]=> array(0) { } } NULL ============================================================ ============================================================ c object(C)#3 (4) { ["public"]=> NULL ["private":"C":private]=> NULL ["protected":protected]=> NULL ["storage":"ArrayObject":private]=> array(3) { ["public"]=> string(4) "test" ["private"]=> string(4) "test" ["protected"]=> string(4) "test" } } NULL ============================================================

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.62 ms | 403 KiB | 8 Q