2012-10-10 25 views
0

我正在用php include添加絕對路徑。如何用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

我使用的東西simular那麼。我使用鏈接的p值來獲取我的頁面。 我拿出你也在這裏引用的片段

$pages_dir = 'inc/content'; 
include($pages_dir.'/'.$p.'.inc.php');