註:Yaf 裡的init 在下預設理解為__construct()
<code>class Order{ private $extend = ''; private $order = ''; public function init(){ parent::init(); $this->order = new Order(); $this->extend = new OrderEx(); } public function listAction(){ $this->order->public(); } public function makeAction(){ $this->extend->public(); } }</code>
與以下寫法有什麼不同嗎?
<code>class Order{ private $extend = ''; private $order = ''; public function init(){ parent::init(); } public function listAction(){ $order = new Order(); $order->public(); } public function makeAction(){ $extend= new extend(); $extend->public(); } }</code>
在下小菜鳥一枚,希望有個良好的程式設計習慣,有些基礎不踏實 還望指點