如何开启PHP错误报告

If you are running into a blank or white page or some other PHP error, but you have no clue what is wrong, you should consider turning on PHP error reporting. This gives you some indication of where or what the problem is, and it is a good first step to solving any PHP problem. You use the error_reporting function to turn on error reporting for a specific file that you want to receive errors on, or you can enable error reporting for all your files at your web server by editing the php.ini file. This saves you the agony of going over thousands of lines of code looking for an error.

如果您遇到空白白页或其他一些PHP错误,但不知道出了什么问题,则应考虑打开PHP错误报告。 这为您提供了问题出在哪里或出了什么的指示,这是解决任何PHP问题的良好的第一步。 您可以使用error_reporting 函数为要接收错误的特定文件打开错误报告,或者可以通过编辑php.ini文件为Web服务器上的所有文件启用错误报告。 这样可以免去遍历数千行代码查找错误的痛苦。

错误报告功能 ( Error_reporting Function )

The error_reporting() function establishes the error reporting criteria at runtime. Because PHP has several levels of reportable errors, this function sets the desired level for the duration of your script. Include the function early in the script, usually immediately after the opening <?php. You have several choices, some of which are illustrated below:

error_reporting()函数在运行时建立错误报告条件。 由于PHP具有多个可报告错误级别,因此此函数将在脚本持续时间内设置所需级别。 通常在打开<?php之后立即在脚本中包含该功能。 您有几种选择,如下所示:

如何显示错误 ( How to Display Errors )

Display_error determines whether errors are printed on the screen or hidden from the user. It is used in conjunction with the error_reporting function as shown in the example below:

Display_error确定是将错误打印在屏幕上还是向用户隐藏。 如下面的示例所示,它与error_reporting函数结合使用:

在网站上更改php.ini文件 ( Changing the php.ini File at the Website )

To see all error reports for all your files, go to your web server and access the php.ini file for your website. Add the following option:

要查看所有文件的所有错误报告,请转到Web服务器并访问网站的php.ini文件。 添加以下选项:

The php.ini file is the default configuration file for running applications that use PHP. By placing this option in the php.ini file, you are requesting error messages for all your PHP scripts.

php.ini文件是运行使用PHP的应用程序的默认配置文件。 通过将此选项放置在php.ini文件中,您正在请求所有PHP脚本的错误消息。

翻译自: https://www.thoughtco.com/php-error-reporting-2694206

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值