A discussion on the use details of the PHP end tag and the Lenovo _php tutorial

Source: Internet
Author: User
When PHP parses a file, it looks for the start , the tag tells PHP to start and stop explaining the code in it. Parsing this way 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.

A 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 #并不能影响到这一点.

As can be seen from the above discussion, even if?> appears in//comments, the PHP parser will think that the PHP parsing is finished (when PHP touches the end tag?>, it simply outputs the contents as it is (unless followed by a new line, see instruction Delimiter) until the next start tag is encountered).
Copy CodeThe code is as follows:
$a = ' testtest ';
Preg_match_all (' |] +href= "([^\"]*) ". *?>| ', $a, $b);
Print_r ($b);

The output is:
Copy CodeThe code is as follows:
:!php preg.php
| ', $a, $b);
Print_r ($b);

How to fix the above problem? or you use/*/to comment, or connect?> with a string connector, as follows:
Copy CodeThe code is as follows:
$a = ' testtest ';
Preg_match_all (' |] +href= "([^\"]*) ". *? '. ' >| ', $a, $b);
Print_r ($b);

The same detail applies to the JS end tag

http://www.bkjia.com/PHPjc/326549.html www.bkjia.com true http://www.bkjia.com/PHPjc/326549.html techarticle when PHP parses a file, will it look for the start? PHP and end tag?, the tag tells PHP to start and stop explaining the code in it. Parsing this way allows PHP to be embedded in a variety of different documents ...

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