Usage Details and associations of PHP end labels

Source: Internet
Author: User

When PHP parses a file, it looks for start. <? Php and end mark?>, Mark to tell PHP to start and stop interpreting the code. This method can embed PHP into different documents. Any content beyond the start and end tags will be ignored by the PHP parser. In most cases, PHP is embedded in HTML documents.

A single-line comment is only commented to the end of the line or the current PHP code block, depending on which one appears first. This means in //...?> Or #...?> The subsequent HTML code will be displayed:?> The PHP mode is jumped out and the HTML mode is returned. // or # does not affect this.

From the above discussion, we can see that even if?> When the PHP parser appears in // annotations, it will also think that PHP Parsing is over (when PHP encounters an end mark?> Then, it simply outputs the original content (unless it is followed by a new line, see the instruction separator) until the next start mark is reached ).Copy codeThe Code is as follows: <? Php
// $ A = '<a href = "test.html" title = "#"> test </a> <a href = "test.html" title = "#"> test </ a> ';
// Preg_match_all ('| <a [^>] + href = "([^ \"] *) ". *?> | ', $ A, $ B );
// Print_r ($ B );

Output:Copy codeThe Code is as follows ::! Php preg. php
| ', $ A, $ B );
// Print_r ($ B );

How can I fix the above problems? Or you can use/**/for comments, or set?> Connect with a string connector, as shown below:Copy codeThe Code is as follows: <? Php
$ A = '<a href = "test.html" title = "#"> test </a> <a href = "test.html" title = "#"> test </a> ';
Preg_match_all ('| <a [^>] + href = "([^ \"] *) ". *? '.'> | ', $ A, $ B );
Print_r ($ B );

This details also applies to JS end labels </script>

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.