Have I misunderstood what heredoc should do?

后端 未结 4 1011
小鲜肉
小鲜肉 2021-01-20 13:03

I\'m very new to PHP so I know I am missing something obvious here - I thought the heredoc function is supposed to retain formatting, line breaks, etc. But whenever I test

4条回答
  •  一向
    一向 (楼主)
    2021-01-20 13:37

    It will produce a string identical to the one you set.

    However, browsers render multiple whitespace condensed to one space character. This is by design.

    To preserve your spaces, you can use the pre element (assuming default browser stylesheet) or white-space: pre CSS property.

    jsFiddle.

提交回复
热议问题