【发布时间】:2013-12-11 06:10:46
【问题描述】:
不同目录级别的两个文件同时调用同一个文件:
// index.php
include('./include/same_file.php');
// Webpages/page1.php
include('../include/same_file.php');
// include/same_file.php
include('../template/header.php'); // failed to open on index.php
fopen('../files/text1.txt'); // failed to open on index.php
file('./files/AA.html'); // failed to open on /include/same_file.php
我已经尝试了几个小时来寻找解决方案,并找到了 dirname(__FILE__) 和 $_SERVER[DOCUMENT_ROOT] 解决方案,但它们都不起作用,因为它们都没有为像我这样的初学者提供详细的教学。
【问题讨论】:
-
你使用的 dirname(FILE) 的详细信息是什么?
-
到目前为止,我只被告知这样做:include(dirname(FILE).'../template/header.php');但不工作。我知道缺少某些东西,但我不知道是什么!
标签: php include document-root dirname