我已经找到了一些解决方案,但不知道发生了什么......
示例 1:
<?php
echo <<< EOD
test
EOD;
示例 2:
<?php
echo <<< 'EOD'
test
EOD;
输出 1,2:
PHP Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or heredoc end (T_END_HEREDOC) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN)
示例 3:
<?php
echo <<< EOD
test
EOD;
?>
示例 4:
<?php
echo <<< 'EOD'
test
EOD;
?>
示例 5:
<?php
echo <<< EOD
test
EOD;
'dummy';
示例 6:
<?php
echo <<< 'EOD'
test
EOD;
'dummy';
输出 3、4、5、6:
test