How to correctly understand PHP's wrong _php tutorial

Source: Internet
Author: User
Summary: When we write a program, it is always unavoidable to make mistakes, no matter how cautious. These errors often confuse the PHP compiler. If developers are unable to understand the meaning of compiler error messages, they are not only useless, but often frustrating.
When we write a program, it is always inevitable to err on the wrong way, no matter how cautious. These errors often confuse the PHP compiler. If developers are unable to understand the meaning of compiler error messages, they are not only useless, but often frustrating.
When compiling a PHP script, the PHP compiler will do its best to report the first problem it encounters. This creates a problem: only when the error occurs does PHP recognize it (this is described in detail later in this article). It is for this reason that the compiler indicates that the line of error, on the surface, may be syntactically correct, or it may be a line that does not exist at all!
A better understanding of the error message can greatly save the time it takes to identify and correct the wrong content. Therefore, in this article, I will try to clarify a number of different types of PHP error messages, and how to correctly understand the meaning of the various error messages during the development process.
The content in this article is not related to the version of PHP that you are applying, because the various errors described in this article are not limited to specific errors for a particular version. In addition, we assume that you are a beginner or intermediate programmer and have been working on programming for six months or a year. How the compiler works
To figure out why the compiler reports errors on a single line, you must first clarify the compiler's mechanism for parsing PHP code. I'm not going to discuss this in detail in this article, but we'll talk about some simple concepts that are more prone to errors.
Variable declaration
If you declare a variable in a statement, it is as follows:
$variable = ' value ';
The compiler first evaluates the value of the right half of the statement (that is, everything to the right of the equals sign). In some programming books, this is represented as the RHS (right half) of the statement. It is precisely this part of the statement that often throws an error. If you use an incorrect syntax, a parsing error occurs.
Parsing errors
Parse Error: Parsing errors, unexpected t_while in C:Program Filesapache groupapachehtdocsscript.php on line 19
Each time a previous error is identified, the parsing error occurs one after the other. Because PHP stops executing the script after the first parsing error, debugging and correcting this set of errors can be especially annoying.
Also, parsing errors have very little information and do not report the line number where the error is. The reason is that when an error occurs, the compiler determines that several lines of syntax appear to be valid until an invalid syntax is encountered, and the most likely scenario is that the expression uses a predefined word, such as;
while = 10; Bad? While is a predefined term and cannot be assigned to a value

http://www.bkjia.com/PHPjc/632430.html www.bkjia.com true http://www.bkjia.com/PHPjc/632430.html techarticle Summary: When we write a program, it is always unavoidable to make mistakes, no matter how cautious. These errors often confuse the PHP compiler. If the developer is unable to understand the compiler error message ...

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