我在根/ lib中包含header_sub.php在同一目录中的header.php。在根文件通常可以直接包括他们这段代码:包括嵌套的PHP文件
include_once('lib/header.php');
但现在我有使用example.php在子目录/博客,如果我使用这些
include_once(../'lib/header.php'); or
include_once($_SERVER['DOCUMENT_ROOT'].'/lib/header.php'); or
include_once(dirname(__FILE__).'/lib/header.php');
header_sub.php不会正确包含。
有没有办法在不修改它们的情况下包含header.php和header_sub.php?
试着把require_once而不是include_once告诉我们你得到了什么错误。 –