PHP error and exception notes and summary (1) error (deprecated,notice,warning)

Source: Internet
Author: User
Tags deprecated ereg parse error php error

"Common Types of errors"

① Syntax error

"Example 1" the end of the program statement is less '; '

<? PHP $username = "Dee"   //less semicolon;  echo$username;


( ! ) 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.

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

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 ';}


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 # ');


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 ';


( ! ) 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 ';


 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 ';


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)

Related Article

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