getInstance這個函數可以更優化點:
static function getInstance()
{
if(!isset(self::$db))
{
$obj = __CLASS__;
self::$db = new $obj;
}
return self::$db;
}
static function getInstance()
{
if(!isset(self::$db))
{
$obj = __CLASS__;
self::$db = new $obj;
}
return self::$db;
}
2015-01-15
$db是不是要聲明為static,不聲明為static會有這樣的語法錯誤:Access to undeclared static property
2015-01-15
方法動態創建怎么看都覺得不太靠譜,get和set魔術方法感覺還是少用為好. 個人感覺就是多人合作開發可能會使用到,也只能用作錯誤提示,沒什么實際意義.
2015-01-09