Summary and performance analysis of php disabling error prompt methods

Source: Internet
Author: User
Tags php error

1. Disable notice error prompt

1. Change error_reporting in the php. Ini file.

Changed:

The code is as follows: Copy code

Error_reporting = E_ALL &~ E_NOTICE

2. If you cannot operate the php. Ini file, you can use the following method:

Add the following code to the page where you want to disable the notice error prompt:

The code is as follows: Copy code

Error_reporting (E_ALL ^ E_NOTICE );

In this case, no more prompts will be prompted.


II. Disable all error messages

Php. ini

Open the PHP. Ini file in the php installation directory.

The code is as follows: Copy code

Find display_errors = On and change it to display_errors = off.

Note: If you have copied the PHP. ini file to the windows directory, you must change display_errors = On in c: windows/php. ini to display_errors = off.

Php program enabled
 

The code is as follows: Copy code

<? Php
// Disable error reporting
Error_reporting (0 );
// Report running errors
Error_reporting (E_ERROR | E_WARNING | E_PARSE );
// Report all errors
Error_reporting (E_ALL );
?>


 

Disabling the error message in terms of performance will increase the server performance load a lot.

Test 1:


Disable error display to test the performance of uninitialized and initialized variables in the 10000000 cycle.

The initialization code of the variable is as follows:

The uninitialized loop code of the variable is as follows:

Test score:


Initialization: average 5.28 seconds

Uninitialized: average 17.2 seconds

Performance Gap: 3.25 times


Average time table:

We can see that disabling PHP error output does not close the php kernel's handling of errors. If a large number of Notice-level errors exist in the code, the php program performance will be reduced.

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.