3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $id; public $handle; public function __construct($id) { $this->id = $id; $this->handle = fopen('php://memory', 'r+'); echo $this->id . ' - construct' . PHP_EOL; } public function __destruct() { echo $this->id . ' - destruct' . PHP_EOL; fclose($this->handle); } public function bar() { echo $this->id . ' - bar - ' . get_resource_type($this->handle) . PHP_EOL; return $this; } public static function create($id) { return new Foo($id); } } $foo = Foo::create(1); var_dump( $foo->bar()->handle ); var_dump( Foo::create(2)->bar()->handle );
Output for git.master, git.master_jit, rfc.property-hooks
1 - construct 1 - bar - stream resource(5) of type (stream) 2 - construct 2 - bar - stream 2 - destruct resource(6) of type (Unknown) 1 - destruct

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:
203.68 ms | 405 KiB | 5 Q