[英]Includes only working on dev server
I have the following code in a php/html file:我在 php/html 文件中有以下代码:
<?php
include('sample.php');
include_once('foo.php');
include('bar.php');
?>
On my dev server (php's built-in server), everything is working fine, on the production server (apache2) though I get a blank page when accessing the file.在我的开发服务器(php 的内置服务器)上,一切正常,在生产服务器 (apache2) 上,尽管访问文件时出现空白页面。 The only way to get to the actual page is by removing all 3 includes, removing a single one or two of them does not resolve the problem.
进入实际页面的唯一方法是删除所有 3 个包含,删除其中的一个或两个并不能解决问题。 In the included files I do include files, which might get loaded more than once with include_once.
在包含的文件中,我确实包含文件,这些文件可能会通过 include_once 多次加载。 Apart from that I have no glue why there is an error since everything is working on my dev server and some of the included files work well in other parts of the app.
除此之外,我不知道为什么会出现错误,因为一切都在我的开发服务器上运行,并且一些包含的文件在应用程序的其他部分运行良好。
It is probable that the configuration of include_path
on your dev server contains .
您的开发服务器上的
include_path
配置可能包含.
, which means: if file is included with relative path, try to find it in the current directory . ,这意味着:如果文件包含在相对路径中,则尝试在当前目录中找到它。 This setting is probably not present on the prod server (see for yourself with
phpinfo()
).此设置可能不存在于 prod 服务器上(使用
phpinfo()
亲自查看)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.