PHP 和 iis - 无法重新定义类
我会收到以下错误:
“Fatal error: Cannot redeclare class ExampleClass in
C:\website\ExampleClass.php on line 5”
但是文件中的第 5 行是:
require_once C:\website\ExampleClass.php
有时,在运行 PHP 网站时, 倾向于认为这是 Web 服务器配置的问题,而不是代码的问题。
iis 中是否有安全设置可以阻止出于任何原因执行脚本(错误/执行尝试过多?)
谢谢,
*编辑*
今天又发生了这种情况,当它发生时,它似乎会影响网站中的所有页面,并且所有页面都会生成相同的错误。 (无法在第 5 行重新定义类)。第 5 行是在单独文件中定义类的行,但似乎只能使用 _once 调用来访问它。
在我清除 IIS 5 中的应用程序池后,该错误消失了。是否知道为什么清除应用程序池会产生任何影响,或者为什么此错误会随机发生?
Occasionally when running a PHP website i get the following error:
“Fatal error: Cannot redeclare class ExampleClass in
C:\website\ExampleClass.php on line 5”
however line 5 in the file is :
require_once C:\website\ExampleClass.php
Now the interesting thing is that this error only occurs every once and awhile, and restarting the web server gets rid of it, so i'm more inclined to believe that its a problem with the web server configuration, and not the code.
Is there a security setting in iis that prevents the execution of scripts for any reason (too many errors / execution attempts?)
Thanks,
* edit *
This happened again today, and when it occurs it seems to affect all pages in the website, and same error is generated across all pages. (Cannot Redefine Class at line 5). Line 5 is the line the class is defined on in a separate file, however it seems to only be accessed using _once calls.
The error went away after i cleared the application pool in IIS 5. Any idea's as to why clearing the application pool would effect anything, or why this error occurs at random intervals?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IIS 无法让 PHP 忘记它已经包含了一个文件。这包括“内存”是每个脚本执行的,并且不会在脚本结束后继续存在。您很可能会使用常规
require
指令在其他地方再次包含该文件。IIS couldn't make PHP forget that it's included a file already. This include "memory" is per-script execution, and doesn't survive past the end of the script. Most likely you are including the file again somewhere else, using a regular
require
directive.