PHP Common Error Analysis

Source: Internet
Author: User

{Error type}: {error cause} in {Error file} on {error line}

Describes which row in which file is causing the error.

Common types of errors typically include the following:

Parse error (parsing errors) is usually accompanied by syntax errors (syntax error), stating that your program does not conform to PHP syntax.

It is the highest-level error and the entire script is not executed at all.

It is generally caused by an expression missing ";" or a variety of parenthesis quotes that are not paired. Read the detailed information to find out where the problem lies.

General syntax errors will give you a hint of the parser code, telling you where the problem is. Like what:

Parse error:syntax error, unexpected t_string in xxx.php on line 9

T_string is a parser code, as the name implies, it represents a string, many error causes will be with the parser code. Through it you can more directly understand the cause of the error.

Unexpected means unexpected, in other words, superfluous.

For more parser codes, please refer to: http://www.php.net/manual/zh/tokens.php or PHP Manual in English version called: List of Parser tokens in Chinese version called: Parser Code Listing

The above error means that your nineth line has an unexpected string.

My Code:

1-7: Slightly

8:test (Array (' a '))

9:xxx ();

Ten: >

How to solve this problem? Delete the nineth line of xxx, it really conforms to PHP syntax.

But that's not what I want, actually my 8th line is missing a ";", the workaround is to add a semicolon at the end of line 8th.

Note: This example also illustrates a problem where the error report says which line, the problem is not necessarily where the line is, or it may be the result of one or more lines in front of it. The most typical example is a program prompt error line number in the last line of the file, you go to see, found that line in addition to ">" No other characters, this situation is usually caused by the lack of quotation marks. You'll have to look in the front for a pair of quotes or some other punctuation. If you want to contradicting, look for the line number does not let go, it is not the problem of PHP.

Fatal error (fatal error), second only to parsing errors, executes to the row where the error occurred and the script terminates.

If the program conforms to PHP syntax, uses undefined functions, or require a nonexistent file, the dead loop causes the program execution to time out, which results in fatal error.

The general performance is:

Fatal error:call to undefined function func () in php100.php on line xxx

In other words you call an undefined func function, which is usually to see if you forget to include the included file, write the wrong function name, or write the wrong file name. (php100.com)

Warning (warning) is slightly lower than the fatal error level, but the program is not terminated because of a script error.

Usually appears in include a nonexistent file, or a program requires a parameter, but you do not pass parameters, and you do not specify the default value of the parameter.

Warning depending on the situation can be avoided, there is no way to avoid, you can add @ forcibly shielded.

Notice (notification), the lowest level, can generally be ignored, does not affect the script to run. Most occurrences occur when a variable or array subscript is undefined.

Note: Most notice can be ignored, but a few notice may also reflect a more serious problem.

For example notice:undefined Variable:sql in xxx.php on line xx

You see that there is a variable "SQL" is undefined, this can be very dangerous, in the case of Register_globals=on, perhaps this error directly become the other people operating the database back door.

In addition, there are some other types of errors, usually not common, I will not say more.

Summarize

In summary, PHP error hints will tell us a lot of things, for us to find the error provides great convenience. Make good use of it, will greatly improve our efficiency and quality of work.

However, while it benefits, it may also reveal sensitive information about the server, which could easily allow attackers to discover vulnerabilities in the server.

PHP development environment Be sure to turn on all error prompts to open the error display. Minimize the occurrence of accidents.

Production environment Be sure to turn off the error display and use the log to record the error. Don't give an opportunity to a conscientious.

PHP Common Error Analysis

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.