3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { private $label; public function __construct($label) { $this->label = $label; } public function __sleep() { echo "Attempt to serialize object with label $this->label\n"; return array('label'); } public function __destruct() { echo "Refcount reached zero for object with label $this->label\n"; } public function throwSomething($unused_parameter) { throw new Exception; } } echo "-- No object in stack trace --\n"; $target = new Example('Target of method call'); try { $target->throwSomething('irrelevant data'); } catch ( Exception $e ) { // Serialize exception, doesn't touch object var_dump(serialize($e)); // Destroy $target, as there are no other references to it unset($target); } echo "-- No object as argument captured in stack trace --\n"; $target = new Example('Target of method call'); $parameter = new Example('Parameter passed but never actually used'); try { $target->throwSomething($parameter); } catch ( Exception $e ) { // Serialize exception, will attempt to serialize $parameter var_dump(serialize($e)); // Destroy $target, as there are no other references to it unset($target); // Attempt to do the same for $parameter, Exception holds a reference unset($parameter); } echo "-- PHP process cleanup begins here --\n";
Output for git.master, git.master_jit, rfc.property-hooks
-- No object in stack trace -- string(383) "O:9:"Exception":7:{s:10:"*message";s:0:"";s:17:"Exceptionstring";s:0:"";s:7:"*code";i:0;s:7:"*file";s:9:"/in/hOYb9";s:7:"*line";i:16;s:16:"Exceptiontrace";a:1:{i:0;a:6:{s:4:"file";s:9:"/in/hOYb9";s:4:"line";i:23;s:8:"function";s:14:"throwSomething";s:5:"class";s:7:"Example";s:4:"type";s:2:"->";s:4:"args";a:1:{i:0;s:15:"irrelevant data";}}}s:19:"Exceptionprevious";N;}" Refcount reached zero for object with label Target of method call -- No object as argument captured in stack trace -- Attempt to serialize object with label Parameter passed but never actually used string(448) "O:9:"Exception":7:{s:10:"*message";s:0:"";s:17:"Exceptionstring";s:0:"";s:7:"*code";i:0;s:7:"*file";s:9:"/in/hOYb9";s:7:"*line";i:16;s:16:"Exceptiontrace";a:1:{i:0;a:6:{s:4:"file";s:9:"/in/hOYb9";s:4:"line";i:36;s:8:"function";s:14:"throwSomething";s:5:"class";s:7:"Example";s:4:"type";s:2:"->";s:4:"args";a:1:{i:0;O:7:"Example":1:{s:14:"Examplelabel";s:40:"Parameter passed but never actually used";}}}}s:19:"Exceptionprevious";N;}" Refcount reached zero for object with label Target of method call -- PHP process cleanup begins here -- Refcount reached zero for object with label Parameter passed but never actually used

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:
28.9 ms | 409 KiB | 5 Q