Skip to content

Multiline strings in PHP

You can create multline strings in PHP. This is particularly useful if you have, for example, HTML markup in PHP code, without the need to bother with single or double quotes messing with your string. Also, IDEs will more likely detect the HTML code correctly and apply syntax highlighting. To create a multiline string, create a so-called heredoc:


function title_and_text() {
    $html= <<<EOT



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.