PHP program error debugging method for php to display the error prompt-PHP source code

Source: Internet
Author: User
The company's servers use the wdcp environment, which is very convenient for installation. However, during the development process, something in the function name may be wrong. The server directly Returns Error 500, there are no error prompts, but it is a headache to tell you the 500 error, so debugging errors are inconvenient, note that I disabled the browser to display the friendly error. The company's server uses the wdcp environment, which is very convenient for installation. However, during the development process, something within the function name may be wrong, the Server Returns Error 500 directly without any error prompt. It is a headache to tell you the Error 500, which is inconvenient for debugging. Note that the Browser display is disabled.

Script ec (2); script

At this time, we need to modify the php. ini configuration file. I don't know where the configuration file is. Please use phpinfo () and search for php. ini. Then you can see the location of php. ini.

Search: display_errors: set the value to on

The Code is as follows:

Display_errors = on

Error_reporting = E_ALL &~ E_DEPRECATED

If we enable the error prompt in php. ini, but it still doesn't work, your program may have an error switch, as shown below:

The Code is as follows:

// Disable Error Reporting
Error_reporting (0 );
// Report running errors
Error_reporting (E_ERROR | E_WARNING | E_PARSE );
// Report all errors
Error_reporting (E_ALL );
?>

If you have this code in your program, we just need to remove it.

Study on the Impact of php notice-Level Error prompts on Program Performance

Here I will use performance testing to prove this inference:

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

Test 2:

Disable Error display and test the performance of array indexes in 10000000 cycles using quotation marks and non-quotation marks.

The code for indexed arrays with quotation marks is as follows:

The code for the array index without quotation marks is as follows:

Test score:

Quotation marks: Average 6.37 seconds

No quotation marks: Average 25.19 seconds

Performance gap: 3.95 times

Average time table:

Conclusion:
From the above example, we can see that too many page errors will lead to poor page performance, so we should try not to close the error to handle php errors. We must ensure that the page has no errors.

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.