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).
//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:
$a = '
testtest
print_r($b);
This detail also applies to the JS closing tag
http://www.bkjia.com/PHPjc/477812.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477812.htmlTechArticleWhen PHP parses a file, it looks for start ?php and end tags?, which tell PHP to start and stop interpretation. code in it. This method of parsing allows PHP to be embedded into various documents...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn