3v4l.org

run code in 300+ PHP versions simultaneously
<?php class App { public function run() { echo 'Hello' . PHP_EOL; } } class AppContainer { private static $app = null; public static function getInstance() { if (null === self::$app) { self::$app = self::makeInstance(); } return self::$app; } private static function makeInstance() { $app = new App(); // do all logic for adding routes etc return $app; } } // Whenever you need it $app1 = AppContainer::getInstance(); $app2 = AppContainer::getInstance(); if ($app1 === $app2) { echo 'yay, same object' . PHP_EOL; } $app1->run(); $app2->run();
Output for git.master, git.master_jit, rfc.property-hooks
yay, same object Hello Hello

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