PHP 临时关闭报错, Turn Off Warning/Error Reporting Temporary

Turn Off Warning/Error Reporting Temporary in PHP

Sometimes, your server side scripts performs operation that are not guaranteed to succeed all the time. For example, connection to another remote service. When the operation fails, PHP provides a warning or a error message. But that message is shown to the web user and may contain sensitive information that you don’t want your visitor to see. The trick to prevent leaking sensitive information in this situation is to temporarily turn off the warning and error messages. Following is an example of how to do it:

$cerl = error_reporting ();
error_reporting (0);
#. . .
# 做点什么事情....
#. . .
error_reporting ($cerl);

 

本文:PHP 临时关闭报错, Turn Off Warning/Error Reporting Temporary