【发布时间】:2013-01-02 20:42:15
【问题描述】:
好吧,我正在尝试运行一个包含一些文件的 cronjob,但是当我通过命令行运行它时,它一直说文件不存在
这里是php文件:
include "../includes/common.php";
require_once('../anotherfile.php');
require_once '../swift/lib/swift_required.php';
//some database things
这是我运行的命令行:
/usr/local/bin/php /home/xxxxx/public_html/cron/somefile.php
这是我得到的错误:
Warning: include(..includes/common.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/cron/somefilek.php on line 3
Warning: include(..includes/common.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/cron/somefilek.php on line 3
Warning: include(): Failed opening '..includes/common.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxxx/public_html/cron/somefilek.php on line 3
Warning: require_once(..anotherfile.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/cron/somefilek.php on line 4
Fatal error: require_once(): Failed opening required '..anotherfile.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxxx/public_html/cron/somefilek.php on line 4
由于某种原因,它没有说明 swift_required.php
【问题讨论】:
-
你确定你没有打错字吗?你的错误说:
include(..includes/common.php)而不是include(../includes/common.php) -
是否有嵌套包含?像 common.php 有一个不起作用的包含...我想我可能读错了错误。
-
john 我已经尝试了两种方法都没有工作 ../ 只是 .. common.php 适用于整个网站,并且有一些包含但它们工作正常
-
它没有提及
swift_required.php的原因是因为您之前有anotherfile.phprequired不包括在内。由于它不能包含anotherfile.php和您require,因此程序会因错误而终止。正如它所说的Fatal error。 -
是的,我明白了,谢谢