我在php include中添加了一个绝对路径。
$ path =“/”;
instead of include('../connect.php');
i want to include like include($path.'connect.php');
答案 0 :(得分:3)
如果您使用的是任何框架,请按照说明操作,否则您可以执行以下操作:
$path = __DIR__;
include($path . '/connect.php'); // change this to match path
答案 1 :(得分:2)
我正在使用类似的东西。我正在使用链接中的p值来获取我的页面。 我拿出了你在这里提到的片段
$pages_dir = 'inc/content';
include($pages_dir.'/'.$p.'.inc.php');