3v4l.org

run code in 300+ PHP versions simultaneously
<?php // ----------------------------------- script1.php -------------- $provider = function() { $instance = new PDO('mysql:......;charset=utf8', 'username', 'password'); $instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $instance->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); return $instance; }; $factory = new StructureFactory( $provider ); $something = $factory->create('Something'); $foobar = $factory->create('Foobar'); // ----------------------------------- script2.php -------------- class StructureFactory { protected $provider = null; protected $connection = null; public function __construct( callable $provider ) { $this->provider = $provider; } public function create( $name) { if ( $this->connection === null ) { $this->connection = call_user_func( $this->provider ); } return new $name( $this->connection ); } }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught PDOException: could not find driver in /in/o1Km6:6 Stack trace: #0 /in/o1Km6(6): PDO->__construct('mysql:......;ch...', 'username', Object(SensitiveParameterValue)) #1 /in/o1Km6(38): {closure}() #2 /in/o1Km6(16): StructureFactory->create('Something') #3 {main} thrown in /in/o1Km6 on line 6
Process exited with code 255.

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