What is <<<_END?

前端 未结 5 1227
生来不讨喜
生来不讨喜 2021-01-04 08:45

I\'m new to PHP and don\'t understand what the point of <<<_END is. Could someone please explain when this should be used? I\'ve looked at various exam

5条回答
  •  抹茶落季
    2021-01-04 09:04

    That syntax is called heredoc

    <<<_END
    some text
    _END
    

    Basically, it's a way of writing a string without worrying about escaping quotes and so on.

    As you've mentioned, it doesn't really provide a lot of benefit over other string formats - although, it does mean you can write a block of HTML without escaping out of PHP with ?>

    It also isn't too popular as its use generally goes against the practice of seperating content from logic by embedding the content in the middle of your script.

提交回复
热议问题