PHP error prompt parsing

Source: Internet
Author: User
Tags parse error php development environment
Let's talk about the PHP error message. The PHP error message from the PHP100 Forum consists of the following parts: {error type }: {error cause} in {error File} on {number of error lines} describes the cause of the error in the row of the file. Common errors... "> <LINKhref =" http://www.php100.com//statics/

 

Let's talk about the PHP error message, from the PHP100 Forum.

PHP error information consists of the following parts:

{Error type }:{ error cause} in {error File} on {error row count}

Describes the cause of the error in the row of the file.

Common error types include:

Parse errors are usually accompanied by Syntax errors, indicating that your program does not conform to the PHP Syntax.

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

It is generally caused by the absence of ";" in an expression or the unpaired brackets. You can see the details of the problem.

A common syntactic error will prompt you with a parser code to tell you where the problem is. For example:

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

T_STRING is a parser code. As its name implies, it represents a string. Many error causes may contain a parser code. You can learn more about the cause of the error.

Unexpected is not expected. In other words, it is redundant.

For more Parser code, see: http://www.php.net/manual/zh/tokens.php or php manual in English called: List of Parser Tokens Chinese version called: Parser code List

The above error indicates that your ninth row has an unexpected string.

My code:

1-7: Omitted

8: test (array ('A '))

9: xxx ();

10:>

How can this problem be solved? Delete xxx from the ninth line, which is indeed in line with the PHP syntax.

But that is not what I want. In fact, there is a ";" missing in my 8th rows. The solution is to add points at the end of row 8th.

Note: This example also illustrates the problem where the error report says yes. The problem may not necessarily be caused by the previous line or several lines. The most typical example is that a program prompts that the number of wrong lines is in the last row of the file. You can see that there are no other characters except ">" in the line. This is generally caused by missing quotation marks. You need to find unpaired quotation marks or punctuation marks. If you have to raise the bar and identify the row number, it is not a php problem.

Fatal Error (Fatal Error) is second only to Parsing Error. When an Error occurs, the script stops running.

Based on the PHP syntax, the program uses undefined functions or require a non-existent file. If an endless loop causes program execution to Time Out, fatal error will occur.

Generally:

Fatal Error: Call to undefined function func () in php100.php on line xx

That is to say, you have called an undefined func function in XX line. At this time, it usually depends on whether you forget to include the file, whether the function name is wrong, and whether the file name is wrong. (PHP100.com)

The Warning is slightly lower than the fatal error level, but the program will not be terminated due to a script error.

It usually appears in include a non-existent file, or a program requires a parameter, but you didn't pass the parameter, and you didn't specify the default value of the parameter.

Warning can be avoided as needed, but it cannot be avoided. You can add @ to force blocking.

Notice (notification), which has the lowest level. Generally, it can be ignored without affecting the script running. Most of the cases occur when the variable or array subscript is undefined.

Note: most notice can be ignored, but a few notice may also reflect serious problems.

For example, Notice: Undefined variable: SQL in xxx. php on line xx

You can see that there is a variable "SQL" undefined, which may be very dangerous. In the case of register_globals = on, maybe this error directly becomes a backdoor for others to operate on the database.

In addition, there are some other types of errors, which are not common at ordinary times. I will not say much about them.

Summary

To sum up, the PHP error prompt will tell us a lot of things, providing great convenience for us to find errors. Making good use of it will greatly improve our work efficiency and quality.

However, when it brings benefits, it may also expose sensitive information on the server, making it easy for attackers to discover server vulnerabilities.

In the php development environment, you must enable all error prompts and enable error display. Minimize accidents.

In the production environment, you must disable error display and use logs to record errors. Do not give a chance to someone with confidence.

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.