PHP包含调用失败

PHP include call fails

我正在编写一系列网页,我想在其中修改显示时间的格式。我已经编写了一个 PHP 函数来执行此操作,并且当它与其余代码位于同一文件中时,该函数可以完美运行。但是,我想在几个相关文件中执行此转换过程,因此我在需要的地方"d like to put the function in an external file that I can simply "include"。但我无法让 "include" 位工作。

这是我用于包含过程的代码:

<?php
  include 'http://www.northcentralflaa.org/header.html';
  include 'http://www.northcentralflaa.org/d.sysadmin/f-time.php';
?>

头文件(第一个"include"行)显示没有问题,但是f-time.php文件没有被引入。

error_log 文件告诉我:

"[07-Jul-2016 11:12:03] PHP Warning: include() [function.include]: Failed opening 'http://www.northcentralflaa.org/d.sysadmin/f-time.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home1/northce1/public_html/d.sysadmin/admin-portal.php on line 19"

这似乎告诉我 - 在“(include_path='.:/usr/lib64/php:/usr/share/pear')”中 - 系统正在子目录中寻找一些文件-据我所知不存在的目录。但是,正如我所说,第一个 "include" 语句非常有效。

FWIW,我还尝试了 HTML SSI 包含过程:

: <!--#include file="http://www.northcentralflaa.org/d.sysadmin/f-time.php" -->

(当然,在 php 括号之外),我已经尝试过使用相对路径而不是绝对路径的两个过程,无论是否有前导点倾斜。我检查了目录和文件名的拼写。即使该函数在基本网页文件中编写时工作完美,我也尝试注释掉整个函数(在 f-time.php 文件中)并仅导入一行 saying

echo "The file was imported";

即使这样也没有出现。我可以进一步寻求解决方案的任何想法?

包括对本地化文件路径的调用,而不是 URL。

<?php
  include 'header.html';
  include 'd.sysadmin/f-time.php';
?>

我找到了修复方法。我不能完全理解它为什么有效,但如果我重写第二个 include commend as

include $_SERVER['DOCUMENT_ROOT'] . '/d.attic/f-time.php'; 

它按预期工作。 (第一个 include 语句不需要重写,这让我很困惑。)