PHP - Heredoc String Creation

PHP traditional string creation method I've mentioned in earlier post. That method common to most of the programming languages. PHP introduces a more robust string string creation tool called Heredoc, it creates multi-line strings without using single or double quotes. This methods seems to be easy but it's too difficult and can be lead to arise errors if you do not properly code the string.


Example:

    <?php
    $my_string = <<<TEXT
                    Welcome to Programming for Beginners Blog <br />
                    This is PHP lesson about the String
TEXT;
    echo $my_string;
   
    ?>

Out put


No comments:

Post a Comment