PHP syntax error, unexpected $end errors how to solve

Source: Internet
Author: User
Tags parse error php error php syntax error

The following PHP error was encountered:parse Error:syntax error, unexpected $end in script.php the line xx after debugging found that the row that produced the error is a row in the middle of the file

  1. $str. = ">\n";
Copy Code

Think of it. The end tag allowed by the PHP interpreter can also be annotated with a single line, i.e.//$str. = ">\n"; is interpreted as having a comment before the end tag, the content of the comment is//$str. = ", and \ n" After?>; will be interpreted as content outside of the PHP block as HTML output out! The result is to $str. = ">\n"; This line adds//comments, instead of a?> end tag, causing the original end tag to be unexpected (unexpected).

Workaround: Remove this line directly.

Small reminder: PHP start and end tags in the row do not write anything else.

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