3v4l.org

run code in 300+ PHP versions simultaneously
<?php class bar { protected $baz = "1"; public function set( $val ) { $this->baz = $val; } public function get() { return $this->baz; } } class foo { private $bar; public function __construct( $bar ) { $this->bar = $bar; } public function __clone() { echo __METHOD__ . "\n"; $this->bar = clone $this->bar; } public function get() { return $this->bar; } } $bar = new bar(); $o1 = new foo( $bar ); $o2 = clone $o1; $o2->get()->set( "2" ); var_dump( $o1->get()->get() ); var_dump( $o2->get()->get() );
Output for git.master, git.master_jit, rfc.property-hooks
foo::__clone string(1) "1" string(1) "2"

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:
46.29 ms | 401 KiB | 8 Q