私は、変数が複数のインクルードの後で設定されていない理由をundestandしません。変数を複数の変数に共有するinclude(php)
はheader.phpの中で、私は
public function defaultShow(){
include(dirname(__FILE__)."/../view/app/header.php");
include(dirname(__FILE__)."/../view/app/accueil.php");
include(dirname(__FILE__)."/../view/app/footer.php");
}
accueil.phpで$ aが設定されている変数$を持っています。それはだ
に動作しますが、私のコードはpublic function defaultShow(){
self::includeView("app/header");
self::includeView("app/accueil");
self::includeView("app/footer");
}
public static function includeView($view){
include dirname(__FILE__)."/../view/".$view.".php";
}
ある場合accueil.phpがロードされますが、$このファイルに空です。
header.phpの中で設定されたすべての変数はaccueil.php
理由で空のですか?回答
ギヨーム
グローバルの$ A; $ a = 'max'; –