[英]What could be the cause of unexpected characters served by the PHP internal web server?
[英]What can cause a web server to not find an XML file?
我有一个PHP脚本,该脚本从xml文件读取以生成表。 它要做的第一件事是检查以确保文件存在。
$path = getcwd();
if(file_exists($path.'\inc\php\kbs.xml')){
$kbs = simplexml_load_file($path.'\inc\php\kbs.xml');
} else {
echo "Error: No KB file found";
}
由于某种原因,它间歇性地找不到文件。 我尝试删除file_exists
一起检查(因为我知道该文件确实存在),但是它有时仍不加载该文件。 我可以刷新页面,每10个页面刷新7次,但不会加载,但有时可以。
在开发过程中,我从未遇到过这个问题,但是一旦投入生产(现在可能已有200个用户使用),它就开始发生。
我该如何解决此问题? (在IIS上运行的PHP 5.2.14)
编辑:错误日志失败时给我以下消息:
Notice: Undefined variable: kbs in <the path> on line 16
Notice: Trying to get property of non-object in <the path> on line 16
Warning: Invalid argument supplied for foreach() in <the path> on line 16
第16行是第一次访问变量$kbs
。 显然,如果找不到该文件,则不会设置$kbs
。
请使用绝对路径,相对路径会使事情变得一团糟。
位置相对于PHP吗? 权限是否允许Web服务器看到它?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.