[請益] PHP的new object()

看板PHP作者 (米沙)時間15年前 (2010/11/09 16:28), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
最近在寫 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)

11/09 16:39, , 1F
create裡面可能會擴充啊...
11/09 16:39, 1F
文章代碼(AID): #1CsGOcME (PHP)
文章代碼(AID): #1CsGOcME (PHP)