3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $b = null; protected static $instance = null; public static function get() { if (static::$instance === null) { static::$instance = new static(); } return static::$instance; } public function __construct() { echo __METHOD__ . PHP_EOL; $this->b = Bar::get(); } public function __destruct() { echo __METHOD__ . PHP_EOL; $this->b->func(); } } class Bar { public $destroyed = false; protected static $instance = null; public static function get() { if (static::$instance === null) { static::$instance = new static(); } return static::$instance; } public function __construct() { echo __METHOD__ . PHP_EOL; } public function __destruct() { echo __METHOD__ . PHP_EOL; $this->destroyed = true; } public function func() { echo __METHOD__ . PHP_EOL; } } Bar::get(); Foo::get();
Output for git.master, git.master_jit, rfc.property-hooks
Bar::__construct Foo::__construct Bar::__destruct Foo::__destruct Bar::func

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