最初に私のファイル構造を示しましょう。
/www/
myfile.php
anotherC.php
a/
b.php
c.php
内部のコードmyfile.php
は次のとおりです。
<?php
include_once("a/b.php");
?>
内部のコードb.php
は次のとおりです。
<?php
include_once("c.php");
?>
そして最後に内部c.php
:
<?php
echo "hello i'm C.php";
?>
だから、私が呼び出すwww/myfile.php
と、出力が得られます:
こんにちは、C.php です。
これらは正常に動作します。しかし、私に変えさせてb.php
ください
<?php
include_once("../anotherC.php"); //or include_once("./c.php"); (it won't work too)
?>
今、私が呼び出すとwww/myfile.php
、エラーが発生します:
警告: include_once(../anotherC.php): ストリームを開けませんでした: No such file or directory in /home/hasib/Desktop/www/a/b.php on line 2 Warning: include_once(): Failed opening '. 2 行目の /home/hasib/Desktop/www/a/b.php に含めるための ./anotherC.php' (include_path='.:/usr/share/php:/usr/share/pear')
今私の質問は、なぜinclude_once("c.php");
完璧に機能したのですか??