3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Obj { public function __construct($mix) { foreach ($mix as $k => $v) { $this->$k = $v; } } public function __toString() { $str = ''; foreach ($this as $k => $v) { $str = "$k => $v\n"; } return $str; } } class A { public $obj; public function setObj($obj) { $this->obj = $obj; } public function getObj() { return $this->obj; } function __sleep() { return ['test' => $this->obj]; } } function printA(A $a) { var_dump($a); serialize(debug_backtrace(0)); } $obj = new Obj(['hello'=>'there']); $a = new A(); $a->setObj($obj); var_dump($a->getObj()); printA($a); var_dump($a->getObj());
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property Obj::$hello is deprecated in /in/hN9eJ on line 6 object(Obj)#1 (1) { ["hello"]=> string(5) "there" } object(A)#2 (1) { ["obj"]=> object(Obj)#1 (1) { ["hello"]=> string(5) "there" } } Warning: serialize(): A::__sleep() should return an array only containing the names of instance-variables to serialize in /in/hN9eJ on line 39 Warning: serialize(): "hello => there " returned as member variable from __sleep() but does not exist in /in/hN9eJ on line 39 object(Obj)#1 (1) { ["hello"]=> string(5) "there" }

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:
102.71 ms | 407 KiB | 5 Q