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

发布于 2024-07-11 03:39:46 字数 294 浏览 5 评论 0原文

我们正在迁移到运行 Windows 2003 和 IIS 6 的新服务器。当我的 PHP 代码运行时,它在特定行上有一个警告(我目前正在期待该警告,但很快就会修复)。 但是,当遇到警告时,它会立即停止处理并在 HTTP 标头中返回 500 错误。 通常,我希望 PHP 输出警告,但继续处理脚本。

当 PHP 遇到警告时,IIS、FastCGI 或 PHP 的配置中是否有某些内容会返回 500 错误?

澄清一下:我不想抑制警告; 我想让它们显示出来。 我不希望脚本因警告而停止处理。

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). However, when it hits the warning, it immediately halts processing and returns a 500 error in the HTTP header. Normally, I would expect PHP to output the warning, but continue processing the script.

Is there something in the configuration for IIS, FastCGI, or PHP that would be returning 500 errors when PHP hits a warning?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

生活了然无味 2024-07-18 03:39:46

弄清楚了问题。 php.ini 中的 log_errors 已设置为 On,但 error_log 未设置。 这导致 PHP 停止一切。 将 display_errors 设置为 on 后,现在会显示警告,以便我可以看到输出中出现问题的位置。

该线程很有帮助: http://forums.iis.net/p/1146102/ 1856222.aspx#1856222

Figured out the issue. log_errors in php.ini was set to On, but error_log was unset. This was causing PHP to stop everything. After setting display_errors to on, the warnings now display so I can see where things are breaking in the output.

This thread was helpful: http://forums.iis.net/p/1146102/1856222.aspx#1856222

岛歌少女 2024-07-18 03:39:46

我不知道 IIS 或 FastCGI,但 afaik php 没有这样的选项。 不过,您可以将 error_reporting(在 php.ini 中)设置为

E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

使警告消失。

I don't know about IIS or FastCGI, but afaik php has no such option. You can however set error_reporting (in your php.ini) to

E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

to make warnings go away.

动次打次papapa 2024-07-18 03:39:46

这在很大程度上取决于您的 PHP 代码,如果您在代码中执行一些复杂的操作并且发生错误,Web 服务器有时会抛出 500 个错误。 我建议您:

  1. 在线上放置一个@以抑制错误,即:

    $x=@my_function($y);

  2. 查看您的网络服务器日志以获取您收到的确切错误消息,然后将其发布到此处,也许我们可以为您提供更好的解决方案。

    查看您的网络

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. I would suggest you:

  1. Put an @ on the line to suppress the error, i.e :

    $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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文