- Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.29
- Fatal error: Abstract function Singleton::__construct() cannot contain body in /in/qaG6N on line 14
Process exited with code 255.
<?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 ***/
private 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();
?>