Parsing: PHP End tag Usage details

Source: Internet
Author: User
This article delves into the use of the end tag in PHP, as well as the related details of the problem, with the need for a friend to refer to.

We know that PHP will look for the start, PHP and end tags when parsing the file?. These tokens tell PHP to start and stop explaining the code in it.

This way of parsing allows PHP to be embedded in a variety of documents that are ignored by the PHP parser in the case of anything other than a pair of start and end tags.

In most cases, PHP is embedded in an HTML document. The

Single-line comment only comments to the end of the line or the current PHP code block, depending on which first appears. This means that in//...? > or # ...? The HTML code after > is displayed:?> jumps out of PHP mode and returns to HTML mode,//or #并不能影响到这一点.

Even if?> appears in//comments, the PHP parser will assume that the PHP parsing is finished (when PHP touches the end tag?>, it outputs the contents as is (unless followed by a new line, see instruction Delimiter) until the next start tag is encountered).

Example:

| ', $a, $b); Print_r ($b); 

Output:

:!php preg.php | ', $a, $b); Print_r ($b); The

can be commented by using the/* * or by connecting the?> with a string connector to fix the above problem, for example:

| ', $a, $b); Print_r ($b); 

Description: This detail also applies to the JS end tag.

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