Php error debugging

Source: Internet
Author: User
Php errors mainly fall into the following three categories: 1. Syntax error programs usually display error messages (errors) during execution ). This type of error will prevent php scripts on the page from executing other tasks. For example, & lt ;? PhpEcho100.Echo100; Echo101 ;? & Gt; execution result Parse... SyntaxHighlight

Php errors mainly fall into the following three categories:
1. Syntax error
In this case, the program usually displays an error message (error) during execution ). This type of error will prevent php scripts on the page from executing other tasks. For example:
Echo 100.
Echo 100;
Echo 101;
?>
Execution result
 
Parse error: syntax error, unexpected ';' in...
 
2. runtime error
Php scripts will not be blocked, but they will be prevented from doing what they want. As follows:
Echo "this is a demo ";
Header ('Location: http://www.example.com /');
// No output header () must be called before any actual output
?>
 
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: \ PhpProject1 \ test. php on line 8
 
 
3. program logic error
This error will not stop php script execution, but will not display the error message. The debugging procedure is generally used to handle exceptions. for example
$ A = 5;
If ($ a = 6 ){
Echo $;
}
?>
The running result is 6.
 
 
 
Error severity:
ERROR
The page script stops running.
WARNING
Page script does not stop running
NOTICE
Page script does not stop running
 
/*
* Ini_set ()
* Error_reporting ()
* Header ()
*
*/
 
 
Header ("Content-type: text/html; charset = utf-8 ");
 
 
Echo $ a; // Notice: Undefined variable:
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 will keep this new value during the script's execution, and will be restored at the script's ending.
Assign a value to the configuration option that is given (specified). during program execution, the configuration option will always use the new value. When the program execution is complete, the configuration option restores the default value of the system.
Ini_set ('display _ errors ', 1); enable display_errors in php. ini
 
Error_reporting (E_ALL );
All errors, warnings, and notes of the error program are reported.
 
 
 
Error_reporting (E_ALL );
Ini_set ('display _ errors ', 1 );
Author: "My PHP path"

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.