Home  >  Article  >  Backend Development  >  About the usage details of PHP end tag?>_PHP Tutorial

About the usage details of PHP end tag?>_PHP Tutorial

WBOY
WBOYOriginal
2016-07-14 10:08:09744browse

When PHP parses a file, it looks for the opening , which tell PHP to start and stop interpreting the code within it. This method of parsing allows PHP to be embedded in various documents. Any content outside a pair of opening and closing tags will be ignored by the PHP parser. In most cases PHP is embedded in HTML documents.

Single-line comments only comment to the end of the line or to the current block of PHP code, whichever comes first. This means that the HTML code after // ... ?> or # ... ?> will be displayed: ?> jumps out of PHP mode and returns to HTML mode, // or # has no effect at this point.
From the above discussion, we can know that even if ?> appears in the // comment, the PHP parser will consider that PHP parsing is over (when PHP encounters the end mark ?>, it will simply leave the following content as is Output (unless immediately followed by a new line, see Instruction Delimiters) until the next start tag is encountered).
//preg_match_all('|]+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 use /* */ to comment, or connect ?> with string concatenation, as follows: