"Common Types of errors"
① Syntax error
"Example 1" the end of the program statement is less '; '
<? PHP $username = "Dee" //less semicolon; echo$username;
Output:
( ! ) Parse error:syntax error, unexpected T_echo in D:\practise\php\Error\error1.php on line 3
Parse Error: Parsing errors
Syntax error: syntax errors
"Error level in PHP" 16
Constant description
E_error |
Fatal run-time error. Terminates program execution. |
E_warning |
(Run-time warning) non-fatal run-time error. Script execution is not paused. |
E_parse |
Syntax parsing error |
E_notice |
Notification (note), indicating a condition that may appear to be wrong |
E_core_error |
Fatal error occurred during PHP initialization startup |
E_core_warning |
Warnings that occur during PHP initialization startup |
E_compile_error |
Fatal compilation error |
E_compile_warning |
Compile-time warning |
...... |
...... |
A. Deprecated the lowest level of error--not recommended or not recommended
"Example 2"
<? PHP if (ereg$matches)) { print_r($matches);} Else { echo ' not found ';}
Output:
Function Ereg () is deprecated in D:\practise\php\Error\error1.php on line 2Array ([0] = Dee)
Deprecated: Deprecated, obsolete (you can use Preg_match instead of the Ereg method), but the program also outputs the results.
"Example 3" (PHP 5.3 or later)
<? PHP Echo mysql_escape_string (' \ ' or 1 = 1 # ');
Output:
Deprecated:mysql_escape_stringFunctionusemysql_real_escape_string() instead . In * * *\' or 1 = 1 #
B. Notice Notification level error-there are some inappropriate areas in the syntax. PHP is a weakly typed language, variables can not be directly used, when the direct use of a variable, it will send a notice level error tells you that the variable is not declared: undefined variable; then an array index, if the subscript is a string type, When using an array index (subscript) without quotation marks, PHP will use it as a constant resolution, and if it is not found, it will be interpreted as subscript.
"Example 4"
<? PHP Echo $dee ; // The program continues to execute Echo ' Continue ';
Output:
( ! ) notice:undefined Variable:dee in D:\practise\php\Error\error1.php on line 2continue
"Example 5"
<? PHP $userInfo Array (' username ' = ' dee ', ' age ' =>28); Echo $userInfo [' username ']; Echo ' ; Echo $userInfo // generates a notice level of error Echo ' ; Echo ' Continue ';
Output:
Use constant age-assumed ' age ' in D:\practise\php\Error\error1.php on line 528continue
Use of undefined constant: undefined constant age
So this kind of writing is not normative.
C. Warning Warning Level ERROR--inappropriate syntax, or the function wants to get two arguments, but only one argument is passed when the function is called, or the parameter's type, the value of the parameter is incorrect
<? PHP Settype ($var// variable var type is set to intvar_dump($var); // set a non-existent type, warning Settype ($var, ' Dee '); Var_dump ($var); Echo ' Continue ';
Output:
int 0settype() [function. Settype]: Invalid type in D:\practise\php\Error\error1.php on line 60Continue
Invalid Type: illegal types
(not finished: Fatal, etc.)
② Environment Error
③ Logic Error
PHP error and exception notes and summary (1) error (deprecated,notice,warning)