2016-07-02 2 views
-2

My 디렉토리에 index.php 파일이 있습니다. PHP에 파일을 어떻게 포함합니까?

내가 시도 모든 경우 :

require_once '../config/test.php'; 
require_once '../../config/test.php'; 
require_once '.../config/test.php'; 
+0

[? 있습니다 PHP 파일 또는 호출 코드에 상대 경로를 포함 (http://stackoverflow.com/questions/7378814/are-php-include-paths- : 당신은 같은 것을 사용 할 수 있습니다 상대 파일 또는 호출 코드) – FirstOne

+0

디렉토리 구조가 나에게 불분명하다. [그래프 제공] (http://stackoverflow.com/a/3455675/4233593) –

답변

2
My/index.php 
My/core/coreEngine.php <--- you are here 
My/config/test.php  <--- you want to go here 

이 파일은 coreEngine.php 내부 core/coreEngine.php

내가 이전의 디렉토리에있는 다른 파일 config/test.php을 포함하려고 파일로 포함하고있다

M으로 돌아가고 싶습니다. y 디렉토리이므로 두 개의 디렉토리가 뒤쪽에 있습니다.

require_once '../../config/test.php'; 

그러나 상대 경로 대신 절대 경로를 사용하는 것이 좋습니다.

require_once($_SERVER['DOCUMENT_ROOT'].'/config/test.php'); 
관련 문제