<?php $str= <<<'NOWDOC' <b>HEREDOC 中的单引号和双引号不会被解析,但是会解析引用变量和特殊字符<br></b> <?php<br> HEREDOC;<br> $a=10;<br> echo>>>HEREDOC<br> <html></html> myAge is $a,and 'aaa' is myName ,now i say "Hello" to everyone, \r\n \t<br> HEREDOC;<br> ?><br> NOWDOC; echo $str; ?> {<br> <?php $a=10; echo<<<HEREDOC <b>result:</b>myAge is $a,and 'aaa' is myName ,now i say "Hello" to everyone, \r\n \t hello<br> HEREDOC; ?> }<br>
The browser displays the output:
Single quotes and double quotes in HEREDOC will not be parsed, but reference variables and special characters will be parsed
HEREDOC;
$a=10;
echo>>>HEREDOC
myAge is $a,and 'aaa' is myName ,now i say "Hello" to everyone, \r\n \t
HEREDOC;
?>
{
result:myAge is 10,and 'aaa' is myName ,now i say "Hello" to everyone,
hello
}
I just learned PHP. When testing NOWDOC, I found that both the html tag and the php tag in NOWDOC were interpreted and executed? I just want to print it out, no points -.-!
heredoc is similar to double quote syntax, nowdoc is only supported by php5.3+, similar to single quote syntax, especially suitable for outputting a large amount of html,
The difference between the two string declaration methods , please take a look at this course: http://www.php.cn/code/20794.html