0
我一直在PHP中定製MVC。它是從頭開始製作的,但是我遇到了一個問題:我的視圖控制器很簡單,但是當我調用方法products()
時,它包含視圖產品的無限次。什麼可能導致這個?php mvc查看加載多時間
//this is the autoload method in view controller
public function __autoload()
{
for ($i=0; $i < count($this->include_files); $i++)
{
require 'views/' . $this->include_files[$i] . '.php';
}
}
//this is the products method in view controller
public function products()
{
$this->include_files[0]='header';
$this->include_files[1]='navigation';
$this->include_files[2]='products';
$this->include_files[3]='footer';
$this->__autoload();
}
我到底做錯了什麼?
能否請您寫的var_dump($這個 - > include_files)的'輸出'前'的'循環。順便說一句,爲什麼不使用'foreach'? – 2012-03-10 12:36:02
這是輸出@OfirBaruch array(4){[0] => string(6)「header」[1] => string(10)「navigation」[2] => string(8)「products」 [3] =>字符串(6)「footer」} – 2012-03-11 15:02:11
@ engr.waqas,我編輯了一下這個問題。請確保我在「翻譯」中沒有犯任何錯誤。 – 2012-03-11 16:18:26