먼저 파일 구조를 설명하겠습니다.
두 레벨 PHP는 현재 디렉토리에서만 작동합니까?
/www/
myfile.php
anotherC.php
a/
b.php
c.php
myfile.php
내부의 코드는 다음과 같습니다
<?php
include_once("a/b.php");
?>
b.php
내부의 코드는 다음과 같습니다 c.php
내부 마침내
<?php
include_once("c.php");
?>
그리고 :
<?php
echo "hello i'm C.php";
?>
,536
hello i'm C.php
이 작품을 잘 : 나는 www/myfile.php
를 호출 할 때
그래서, 내가 출력을 얻을.
Warning: include_once(../anotherC.php): failed to open stream: No such file or directory in /home/hasib/Desktop/www/a/b.php on line 2 Warning: include_once(): Failed opening '../anotherC.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/hasib/Desktop/www/a/b.php on line 2
지금 내 질문은 include_once("c.php");
가 완벽하게 근무한다
www/myfile.php
를 호출 할 때 나 지금 <?php
include_once("../anotherC.php"); //or include_once("./c.php"); (it won't work too)
?>
에 b.php
을 변경할 수 있습니다, 나는 오류를 얻을
include_path는 무엇입니까? –
내 권장 사항 : 문서 루트 ('$ _SERVER [ 'DOCUMENT_ROOT']')부터 절대 경로를 사용하십시오. 장점은 다음과 같습니다. 실제 코드의 경로를 변경하지 않고도 파일을 이동할 수 있습니다. 중간 파일을 삭제하면 마지막 파일에서 원하는 파일에 계속 액세스 할 수 있습니다. 등등 ... – aleation
@AlexHowansky, 내 포함 경로 :/usr/share/php :/usr/share/pear –