php 字符串heredoc结构和nowdoc结构的区别

//heredoc: 1.相当于双引号--解析 2.php5.3后可以初始化静态变量和类的常量,属性

//heredoc php4引入
/*
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
*/


//nowdoc: 1.相当于单引--不解析  2. 可以在任何静态数据里使用,用来初始化类的常量,属性

//nowdoc php5.3引入
echo <<<'EOT'
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;

原文地址:https://www.cnblogs.com/zhaozhilu/p/2371233.html