简体   繁体   English

如何隔离不需要的 PHP 错误消息?

[英]How do I isolate unwanted PHP error messages?

I am using wamp and need to know why I am getting server error messages appear in all browsers.我正在使用 wamp 并且需要知道为什么我会在所有浏览器中出现服务器错误消息。 (see grab). (见抓取)。 I have turned error display off in php.ini and cannot see anywhere in the httpd.conf file that would be displaying these.我在 php.ini 中关闭了错误显示,并且在 httpd.conf 文件中看不到任何显示这些的地方。 I would appreciate some help as to how I can troubleshoot this problem.对于如何解决此问题,我将不胜感激。 If anyone requires further code or information, I would be happy to supply at fiddle.如果有人需要更多代码或信息,我很乐意在小提琴中提供。

I am using php5.3.5 and apache 2.0.53.我正在使用 php5.3.5 和 apache 2.0.53。

Thanks谢谢

在此处输入图像描述

Are you sure display_errors isn't being set at runtime by some function in your code?您确定display_errors没有在您的代码中由某些 function 在运行时设置吗? ini_set can be used to set that value at runtime, as shown in this PHP doc example: ini_set可用于在运行时设置该值,如此 PHP 文档示例所示:

<?php
echo ini_get('display_errors');

if (!ini_get('display_errors')) {
    ini_set('display_errors', 1);
}

echo ini_get('display_errors');
?>

display_errors is changeable PHP_INI_ALL ( documentation ). display_errors是可变的PHP_INI_ALL文档)。

This means it can be enabled in .htaccess , or in a running script using ini_set() .这意味着它可以在.htaccess中启用,或者在使用ini_set()的运行脚本中启用。 Check your .htaccess files;检查您的 .htaccess 文件; note that the server (in default config) checks .htaccess files in parent directories as well - so if your site is in /var/www/example.com/htdocs , check for .htaccess in each of the directories in this path.请注意,服务器(在默认配置中)也会检查父目录中的 .htaccess 文件 - 因此,如果您的站点位于/var/www/example.com/htdocs中,请检查此路径中每个目录中的.htaccess文件。

i have turned error display off in php.ini我在 php.ini 中关闭了错误显示

Did you check that the php.ini file you changed/checked was the one PHP is using?您是否检查过您更改/检查的 php.ini 文件是否是 PHP 正在使用的文件? (shown by phpinfo()) (由 phpinfo() 显示)

Did you restart the webserver after changing the php.ini file?更改 php.ini 文件后是否重新启动了网络服务器?

What grab?什么抢? If the q's above don't resolve your problem please provide the text of the error message.如果上面的 q 不能解决您的问题,请提供错误消息的文本。

looks like you are using zend framework.看起来你正在使用 zend 框架。 if you do not want to show error messages.如果您不想显示错误消息。 (anyway turning off errors won't fix them) (无论如何关闭错误不会修复它们)

option 1. change application environment.选项1.改变应用环境。 edit your bootstrap file (in public directory) find following lines编辑您的引导文件(在公共目录中)找到以下行

defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

to following跟随

defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

option 2. edit your application.ini (in application/configs directory) file.选项 2. 编辑您的 application.ini(在 application/configs 目录中)文件。 change all phpSettings.display_errors=1 to phpSettings.display_errors = 0.将所有 phpSettings.display_errors=1 更改为 phpSettings.display_errors = 0。

anyway I recommend using option 2.无论如何,我建议使用选项 2。

but remember turning off errors won't fix them.但请记住关闭错误不会修复它们。 if you post your code may be we can help.如果您发布您的代码,我们可以提供帮助。

From the OP's comment:从OP的评论:

In php info file, display_errors is shown as on.在 php 信息文件中,display_errors 显示为 on。 In the php.ini file it is disabled: ;display_errors = On.在 php.ini 文件中,它被禁用:;display_errors = On。 why is this happening.为什么会这样。 I have checked for multiple ini files, but can only see the 1.我检查了多个ini文件,但只能看到1。

If the option is commented out in php.ini , it's not disabled: it means "use default".如果该选项在php.ini中被注释掉,则它没有被禁用:它意味着“使用默认值”。 IIRC, the default here is On . IIRC,这里的默认值为On Add the line display_errors = Off to php.ini.将行display_errors = Off添加到 php.ini。

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

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