require_once()
が関数内で使用されている場合に、スコープをグローバル スコープに設定する方法を探していrequire_once()
ます。次のコードのようなものが機能するはずです。
ファイル `foo.php':
<?php
$foo = 42;
実際のコード:
<?php
function includeFooFile() {
require_once("foo.php"); // scope of "foo.php" will be the function scope
}
$foo = 23;
includeFooFile();
echo($foo."\n"); // will print 23, but I want it to print 42.
のスコープを明示的に設定する方法はありrequire_once()
ますか? 良い回避策はありますか?