简体   繁体   English

PHP警告导致脚本在运行FastCGI的IIS上暂停

[英]PHP warnings cause script to halt on IIS running FastCGI

We are migrating to a new server running Windows 2003 and IIS 6. When my PHP code runs, it has a warning on a particular line (which I'm expecting at the moment but will fix shortly). 我们正在迁移到运行Windows 2003和IIS 6的新服务器。当我的PHP代码运行时,它会在特定行上发出警告(我现在期待但很快就会修复)。 However, when it hits the warning, it immediately halts processing and returns a 500 error in the HTTP header. 但是,当它遇到警告时,会立即停止处理并在HTTP标头中返回500错误。 Normally, I would expect PHP to output the warning, but continue processing the script. 通常,我希望PHP输出警告,但继续处理脚本。

Is there something in the configuration for IIS, FastCGI, or PHP that would be returning 500 errors when PHP hits a warning? 在遇到警告时,IIS,FastCGI或PHP的配置中是否会出现500个错误?

To clarify: I don't want to suppress the warnings; 澄清:我不想压制警告; I want them to display. 我希望他们展示。 I do not want the script to stop processing on warnings. 我不希望脚本停止处理警告。

Figured out the issue. 找出问题所在。 log_errors in php.ini was set to On , but error_log was unset. php.ini中的log_errors设置为On ,但未设置error_log This was causing PHP to stop everything. 这导致PHP停止一切。 After setting display_errors to on , the warnings now display so I can see where things are breaking in the output. display_errors设置为on ,现在会显示警告,以便我可以看到输出中的内容在哪里断开。

This thread was helpful: http://forums.iis.net/p/1146102/1856222.aspx#1856222 这个帖子很有帮助: http//forums.iis.net/p/1146102/1856222.aspx#1856222

I don't know about IIS or FastCGI, but afaik php has no such option. 我不知道IIS或FastCGI,但是afaik php没有这样的选择。 You can however set error_reporting (in your php.ini ) to 但是,您可以将error_reporting (在您的php.ini )设置为

E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

to make warnings go away. 警告消失了。

That depends very much on your PHP code as well, if you are doing something complicated within the code and an error occurs, web servers sometimes throw 500 errors. 这在很大程度上取决于你的PHP代码,如果你在代码中做了一些复杂的事情并且发生错误,web服务器有时会抛出500个错误。 I would suggest you: 我建议你:

  1. Put an @ on the line to suppress the error, ie : 在行上放一个@来抑制错误,即:

    $x=@my_function($y); $ X = @创建my_function($ y)基

  2. See your web server logs for the exact error message you get, then post it here and perhaps we could offer you a better solution. 查看您的Web服务器日志以获取确切的错误消息,然后将其发布到此处,也许我们可以为您提供更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM