2012-10-10 6 views
0

PHP 포함과 함께 절대 경로를 추가하고 있습니다.PHP로 절대 경로를 추가하는 방법

$ path = "/"; 당신이 어떤 프레임 워크를 사용하는 경우

instead of include('../connect.php'); 

i want to include like include($path.'connect.php'); 
+1

무엇이 당신을 멈추게합니까? –

+0

가능한 중복 http://stackoverflow.com/questions/344823/how-do-i-format-a-php-include-absolute-rather-than-relative-path – Marcus

답변

3

하고 그렇지 않으면 다음을 수행 할 수 있습니다, 그에 따라 : 다음 그 시뮬 뭔가를 사용하고

$path = __DIR__; 
include($path . '/connect.php'); // change this to match path 
2

. 내 페이지를 가져 오기 위해 링크에서 p 값을 사용하고 있습니다. 내가 추천 한 스 니펫을 꺼냈다

$pages_dir = 'inc/content'; 
include($pages_dir.'/'.$p.'.inc.php'); 
관련 문제