1

我对 php heredoc 有疑问。我正在尝试做这样的事情。

$heredoc = <<<_HERE
This is the way
I try to use the
heredoc, but apparently
something is going wrong
_HERE;

显然我应该得到这个:

This is the way
I try to use the
heredoc, but apparently
something is going wrong

但我明白了:

这是我尝试使用heredoc的方式,但显然出了点问题

它没有格式化,主要思想是获取格式化文本。

有人能帮助我吗?

4

2 回答 2

2

使用前置标签:

$heredoc = <<<_HERE
<pre>
This is the way
I try to use the
heredoc, but apparently
something is going wrong
</pre>
_HERE;
于 2013-02-25T04:51:05.267 回答
0

尝试

<?php
    $heredoc = <<<_HERE
This is the way
I try to use the
heredoc, but apparently
something is going wrong
_HERE;

    echo "<pre>";
    echo $heredoc;
    echo "</pre>";
?>
于 2013-02-25T04:52:28.557 回答