私は単純なシングルトンクラスを持っています:
class controller {
// Store the single instance of controller
private static $_controller = null;
public static $user;
public static $db;
public static $page;
public static $code;
// construct the class and set up the user & db instances
private function __construct() {
self::$db = new db(HOST, USER, PASS, DB);
self::$user = new user();
self::$page = new page();
self::$code = new code();
}
// Getter method for creating/returning the single instance of this class
public static function getInstance() {
if (!self::$_controller) {
self::$_controller = new self();
}
return self::$_controller;
}
}
そして、私はそれを次のように呼び出します (そしてテストします):
$load = controller::getInstance();
print_r($load::$db->query('SELECT * FROM `users`'));
しかし、その後、PHP から次のエラーが発生します。
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
このコードは PHP 5.3 で動作しますが、PHP 5.2 を実行しているサーバーでは動作しません
何が起きてる?