0
私はカスタムメイドのMVCをPHPで作成しています。php mvc load load multiple times
私のビューコントローラはかなりシンプルですが、メソッドproducts()
を呼び出すと、ビュー製品は無限に含まれています。これは最初から作成されていますが、問題が発生しました。これを引き起こす原因は何ですか?
//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();
}
私はここで間違っていますか?バルーク @ofir
を使用するときに 'のために前に' 'のvar_dump(の$ this - > include_files)の出力を記入してくださいすることができ、答え、その作業罰金を持っていました'ループ。ところで、なぜforeachを使わないのですか? –
これはout putです@OfirBaruch array(4){[0] => string(6) "header" [1] => string(10) "navigation" [2] => string(8) "products" [3] => string(6) "footer"} –
@ engr.waqas、私はちょっと質問を編集しました。翻訳に間違いがないことを確認してください。 –