<?PHP class Session{ private static $instance; function __construct() { session_start(); echo 'Session object created<BR><BR>'; } public static function getInstance() { if (!self::$instance) { self::$instance = new Session(); } return self::$instance; } }
Give it a try. You had an additional bracket.
The error was in the line function __construct() . He created a function and then an empty set of brackets (this is actually not an error).
Then you never stopped working on the design, so you fixed the error when trying to use an open parameter inside a function, which is invalid syntax.
This is why we make consistent placements in brackets, so we always put things in the same place and, therefore, we can easily find the wrong placements.
source share