1

phpヒアドキュメントに問題があります。私はこのようなことをしようとしています。

$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

しかし、私はこれを取得します:

これは私がヒアドキュメントを使おうとする方法ですが、どうやら何かがうまくいかないようです

フォーマットされていません。主なアイデアは、フォーマットされたテキストを取得することです。

誰かが私を助けてくれますか?

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 に答える