3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class DbConnection { private $dsn; private $initialized = false; public function __construct($dsn) { $this->dsn = $dsn; } private function init() { $this->initialized = true; // socket stuff happens here, much like with PDO } public function query($queryString) { $this->initialized || $this->init(); // irrelevant from here on return ['query' => $queryString, 'dsn' => $this->dsn]; } } $db_conn = new DbConnection('mysql://something'); var_dump( $db_conn, $db_conn->query('SELECT * FROM foo'), $db_conn->query('SELECT * FROM bar') );
Output for git.master, git.master_jit, rfc.property-hooks
object(DbConnection)#1 (2) { ["dsn":"DbConnection":private]=> string(17) "mysql://something" ["initialized":"DbConnection":private]=> bool(true) } array(2) { ["query"]=> string(17) "SELECT * FROM foo" ["dsn"]=> string(17) "mysql://something" } array(2) { ["query"]=> string(17) "SELECT * FROM bar" ["dsn"]=> string(17) "mysql://something" }

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:
31.72 ms | 402 KiB | 8 Q