3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Database { private static $database; private function __construct() { // Nothing } public static function getInstance() { if (!$this->database) { $this->database = new Database(); } return $this->database; } } $database = new Database();
based on pUPki
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to private Database::__construct() from invalid context in /in/mBB0L:21 Stack trace: #0 {main} thrown in /in/mBB0L on line 21
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: Call to private Database::__construct() from invalid context in /in/mBB0L on line 21
Process exited with code 255.