Home  >  Article  >  php教程  >  通过PHP.ini关闭php错误信息回显的方法

通过PHP.ini关闭php错误信息回显的方法

WBOY
WBOYOriginal
2016-06-13 09:37:18801browse

   php的错误回显为代码调试提供了诸多方便,可以让我们快速找到错误所在,不过有时候,显示错误信息会使一些敏感信息暴露出来,对程序安全造成负面影响,为此,通过php.ini配置文件,我们可以在不调试程序的时候将其关闭,方法如下:

  打开PHP.ini,找到display_errors,将后面的值改为off,同时设置error_reporting为E_ALL。如下所示:

  display_errors = Off

  error_reporting = E_ALL

  如下也可以:

  display_errors = Off

  error_reporting = E_ALL & ~E_NOTICE

  注意:如果设置display_errors = Off不起效的话,请将log_errors设置为Off。根据PHP官方资料,当log_errors设置为On时,就必须指定error_log文件,如果未指定或者指定的文件无写权限,那么同样会使display_errors=Off失效,错误信息还是会被显示出来,所以说,将log_errors = Off,问题就彻底解决了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn