1
我不明白爲什麼這個錯誤在PHP 5.4中。嚴格標準:非靜態方法dbInstance :: getInstance()
嚴格的標準:非靜態方法dbinstance具備::的getInstance()不應該被靜態調用
類是:
class dbInstance
{
private static $db;
public static function getInstance()
{
if (! self::$db) self::$db = new db();
return self::$db;
}
}
我把它想:
$registry->db = $db = dbInstance::getInstance()
謝謝
你在哪裏實際調用方法有關係嗎? – 2012-07-27 12:44:11
只爲記錄,[單身是邪惡](http://programmers.stackexchange.com/questions/40373/so-singletons-are-bad-then-what) – 2012-07-27 12:44:20
@TimCooper - $ registry-> db = $ db = dbInstance :: getInstance() – keepwalking 2012-07-27 12:46:35