看板 PHP 關於我們 聯絡資訊
最近在寫 xoops的modules 其中有個 基本的物件問題 // classa.php: class SimpleA { var $calss_name; function SimpleA() { } function get1() { $xoopsobject = $this->create(); return $xoopsobject; } function get2() { $xoopsobject = new $this->calss_name(); return $xoopsobject; } } // SimpleObj.php: include_once('classa.php'); class SimpleObj { $this->one = 1; } class SimpleHandler extends SimpleA { function SimpleHandler(&$db) { $this->calss_name = 'SimpleObj'; } function create() { $tmp = new SimpleObj(); return $tmp; } } // index.php; include_once('SimpleObj.php'); $objHandler = new SimpleHandler(); $objHandler->get1(); $objHandler->get2(); 上述兩個 結果是一樣的 請問一下 get2 這樣做缺點在哪裡??? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.204.23.59 ※ 編輯: mesak 來自: 123.204.23.59 (11/09 16:31)
LewisHamiltn:create裡面可能會擴充啊... 11/09 16:39