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 ). <? 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); the output is ::! Php preg. php | ', $ a, $ B); // print_r ($ B); www.2cto.com how to fix the above problem? Or you can use/**/for comments, or set?> Connect with a string connector, as shown below: <? Php $ a = '<a href = "test.html" title = "#"> test </a> <a href = "test.html" title = "#"> test </> '; preg_match_all ('| <a [^>] + href = "([^ \"] *) ". *? '.'> | ', $ A, $ B); print_r ($ B); this details also apply to JS end labels </script>