3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Singleton { public static function getInstance() { static $instance = null; if (null === $instance) { $instance = new static(); } return $instance; } abstract protected function __construct(); // prevent new instances using "new" final private function __clone(){} // prevent cloning final private function __wakeup(){} // prevent unserializing } class odb extends Singleton { /*** Credentials ***/ private $sPDOHost = 'localhost'; private $sPDOUser = 'username'; private $sPDOPass = 'password'; private $sPDODB = 'database'; /*** Main Constructor ***/ protected function __construct() { /*try { $this->oPDO = new PDO('mysql:host=' . $this->sPDOHost . ';' . 'dbname=' . $this->sPDODB, $this->sPDOUser, $this->sPDOPass); } catch (PDOException $oEx) { die('MySQL/PDO Connection failed: <br /><pre>' . $oEx->getMessage() . "</pre>"); return false; }*/ echo "hi"; } } $Test = odb::getInstance(); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Private methods cannot be final as they are never overridden by other classes in /in/DXoqm on line 15 Warning: Private methods cannot be final as they are never overridden by other classes in /in/DXoqm on line 16 Warning: The magic method Singleton::__wakeup() must have public visibility in /in/DXoqm on line 16 hi

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