PHP Error Debugging _php tutorial

Source: Internet
Author: User
PHP error categories, mainly in the following three major categories:
1. Syntax errors
The program usually displays an error message when it is executed. This type of error prevents the page PHP script from performing other tasks. Such as:
Echo 100.
Echo 100;
Echo 101;
?>
Execution results

Parse error:syntax error, unexpected '; ' in ...

2. Run-time error
does not prevent the PHP script from running, but it prevents the script from doing what it wants to do. As follows:
echo "This is a demo";
Header (' location:http://www.example.com/');
Header () cannot have any output header () before any actual output must be called
?>

Execution Result:
This is a demo

Warning:cannot Modify header Information-headers already sent by (output started at e:\phpproject1\test.php:7) in E:\Ph Pproject1\test.php on line 8


3. Program Logic Error
This error does not prevent the PHP script from executing, nor does it display an error message. The usual debug program means is exception handling.
$a = 5;
If ($a =6) {
Echo $a;
}
?>
Operation result is 6



Error level:
Wrong error
Page script will stop running
Warning warning
Page scripts do not stop running
Notify notice
Page scripts do not stop running

/*
*ini_set ()
*error_reporting ()
*header ()
*
*/


Header ("Content-type:text/html;charset=utf-8");


echo $a; notice:undefined variable:a
echo "
+++++++++++++++++++++
";
echo "This is a notice:undefined variable";


echo "

”;
Var_dump ();
Echo
+++++++++++++++++++++
";
echo "This ia a Warning level Warning:wrong parameter count for Var_dump () ...";


echo "

”;
Ech "This is a demo";
Echo
+++++++++++++++++++++
";
echo "This ia a Warning level Warning:wrong parameter count for Var_dump () ...";
?>



Ini_set ()
Sets the value of a configuration option
String Ini_set (String $varname, String $newvalue)
Sets the value of the given configuration option. The configuration option would keep this new value during the script ' s execution, and would be a restored at the script ' s Endi Ng.
To assign a value to the configuration option given (specified), the configuration option will keep the newly assigned value in use during program execution. When the program finishes executing, the configuration option restores the system's default values.
Ini_set (' display_errors ', 1); Open the display_errors in php.ini

Error_reporting (E_all);
All errors, warnings and notices in the error procedure.



Error_reporting (E_all);
Ini_set (' display_errors ', 1);
Author "My Path to PHP"

http://www.bkjia.com/PHPjc/478645.html www.bkjia.com true http://www.bkjia.com/PHPjc/478645.html techarticle PHP Error categories, mainly in the following three major categories: 1. Syntax error program this is usually done with an error message. This type of error will block page p ...

  • 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.