Is the PHP error report setting invalid?

Source: Internet
Author: User
Is the PHP error report setting invalid? In this case, the configuration file contains the error report (display_errors = On; and error_reporting = E_ALL &~ E_NOTICES), but I want to close the error report in the program,
Ini_set ('display _ errors ', 0 );
Error_reporting (0 );

Why not? Even if the above two functions are used, a fatal error is always reported. Can't it be blocked? Must I change the configuration file to OFF?
So I read the manual. There is a saying:
Note:
Although display_errors can also be set at runtime (using ini_set (), any runtime setting in the case of a fatal error in the script is invalid. In this case, the operation that is expected to run is not executed.

How can we solve this problem? It means that your program has a fatal error. is any ini_set invalid? Check whether the error report is displayed. check the ini configuration. So it is impossible to modify the report temporarily? You can only modify the configuration and then restart the service ....


Please explain ..



Reply to discussion (solution)

If your error occurs before ini_set ('display _ errors ', 0 );
The error message must be output.
Most of the fatal errors are syntax errors, which must occur before running.

You can direct error messages to log files.
You can also use different php. ini files for the development environment and running environment.

Ini_set ('display _ errors ', 'off ');
Error_reporting (0 );

Put in? Top face ??.

If your error occurs before ini_set ('display _ errors ', 0 );
The error message must be output.
Most of the fatal errors are syntax errors, which must occur before running.

You can direct error messages to log files.
You can also use different php. ini files for the development environment and running environment.




However, the moderator, my current company's server error report is opened in the configuration file, but it did not report a fatal error, when the program is started, ini_set ('display _ errors ', 0) is used. if I want to manually set it to 1, an error will be reported. why?

Display_errors indicates an error.
How can an error be displayed when you disable it?
The file that redirects the error message does not indicate that display_errors can be disabled, but the output device is changed.

Some errors occur only when the function is running. for example, if the function lacks a parameter, the divisor is 0 .....

Display_errors indicates an error.
How can an error be displayed when you disable it?
The file that redirects the error message does not indicate that display_errors can be disabled, but the output device is changed.

Some errors occur only when the function is running. for example, if the function lacks a parameter, the divisor is 0 .....



Yes. now, no error is reported when display_errors is set to 0. but I didn't say it in my original post.

Are you confused by yourself?
Display_errors = On

All errors here will be reported.

Ini_set ('display _ errors ', 0 );

No errors are reported here.

Are you confused by yourself?
Display_errors = On

All errors here will be reported.

Ini_set ('display _ errors ', 0 );

No errors are reported here.






It should be that I am not directly expressing enough,
Yes. now, whether it is on or OFF in the PHP configuration file,
I hope that the ini_set function or error_reporting function can be used in the program to quickly change the error or block the error. Both are invalid. But I found it effective on the company server. Yes

Do not do this unnecessary thing
1. if the error display is disabled, the errors in the syntax analysis phase will directly cause the HTTP 500 error.
Therefore, at least enable the error display and redirect to the error log.
2. all errors generated during running can be redirected to the custom error handler through the set_error_handler function.
In the custom error handling program, you can implement the expected action as you wish.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.