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>