PHP Debugging Summary

Source: Internet
Author: User

PHP Debugging Summary
One, the environment, such as to see if the installation extension is in effect, is always supported by an extension.
You can build a phpinfo.php in the web directory
Enter it on the inside
<?php
Phpinfo ();
?>
A visit to the browser will output PHP-related environment and module information.


Second, debug the code error message.
1, by setting display_errors, control PHP error when the output error message, general development environment, can be opened, the official online environment to close.
Open in the way:
1), the communication modifies the display_errors in the php.ini file, if it is off means that the error message is not output when an error occurs, the development environment can be changed to: Display_errors = ON, and then restart Apache
2), Open in PHP code: Add: Ini_set ("Display_errors", "on") at the beginning of the code;
Any options that need to be modified in php.ini can be modified in code using the Ini_set method.

2, setting the error level
Use the Error_reporting function to set the error level, as in the above, you can also modify the php.ini or set it in code, which is set as an example in the code.
error_reporting (0);//Disable error Reporting
Error_reporting (e_all ^ e_notice);//Display all error messages except E_notice
Error_reporting (E_all^e_warning^e_notice);//Displays all error messages except e_warning E_notice
Error_reporting (E_error | e_warning | E_parse);//Display run-time errors with error_reporting (e_all ^ e_notice); Error_reporting (E_all);//Show All errors

In general, notice class errors can be ignored, so common
Error_reporting (e_all ^ e_notice);

Combined with the above two points, usually development will add these two lines in front of the portal file, for example:
<?php
Defines a constant, whether debug mode is turned on.
Define (' DEBUG ', true);
If turned on, the error output is turned on and the error setting is not output except for notice.
if (DEBUG)
{
Error_reporting (e_all ^ e_notice);
Ini_set (' display_errors ', ' on ');
}
If non-debug mode, turn off error output and set error do not output.
Else
{
error_reporting (0);
Ini_set (' display_errors ', ' Off ');
}


3, coding issues
Development document encoding and browser output encoding, after MySQL encoding, unified set to UTF-8 format.
1,notepad++ and Zend Studio can be set, specifically Baidu.
2, the output settings are prepended to the code.
Header ("Content-type:text/html;charset=utf-8")


Summarize:
Generally at the beginning of the file execution at the time of development. Add this paragraph.
<?php
Header ("Content-type:text/html;charset=utf-8");
Define (' DEBUG ', true);
if (DEBUG)
{
Error_reporting (e_all ^ e_notice);
Ini_set (' display_errors ', ' on ');
}
Else
{
error_reporting (0);
Ini_set (' display_errors ', ' Off ');
}

Your other code

?>

PHP Debugging Summary

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.