1
私は共通ファイルを持つ複数のサイトに分割されたアプリケーションを持っています。構造は次のようになります...サイトルート外のファイルでrequire_once()を使用しています
|
|--[Site A] <--Web site A points here
| |-- (Files and folders)
|
|--[Site B] <--Web site B points here
| |-- (Files and folders)
|
|--[Includes] <--common files are here
は私がサイトAまたはBにいる場合は、私はこのような何か:
require_once(include.php)
をすべてが正常に動作しますが、私はこれを行う場合:
をrequire_once(../Includes/include.php)
私はエラーが発生します。
私は、このような
$path = explode("\\" , __DIR__);
for ($i = 1; $i <= 2; $i++) { array_pop($path); }
$path = implode("\\" , $path) . "\\includes\\initialize.php" ;
として、パスを解析するために、いくつか取材をしていて、その周りに、これは動作しますが、私は()のrequire_onceを使用して、よりエレガントな解決策を探しています
感謝を取得しています。
'のrequire_onceを(使用する必要があります../ Includes/include.php) ' - 引用符がないと誤っているのですか、それとも実際のコードのようですか? – Jon
これは以前に尋ねられましたhttp://stackoverflow.com/questions/2370053/how-to-include-file-outside-document-root – gosukiwi