Home >Backend Development >PHP Tutorial >A brief discussion on the <<< operator in PHP A brief discussion on early childhood family education A brief discussion on forest fire prevention A brief discussion on network promotion
PHP provides a method of constructing a multi-line string sequence using the <<< operator, usually called a here-document or expressed as the abbreviation of heredoc.
This method elaborates the literal value of the string and preserves the string's underscores and other whitespace (including indentation) in the text. For example:
<?php $author ='wixy'; echo <<<_END Thisis a Headline Thisis the first line. Thisis the second line. ---Writtenby $author. _END; ?> </p> <p>The PHP parser will output all the content between the two _END tags, which is equivalent to a string quoted with double quotes. <br>This means that we can write an entire HTML language directly in PHP code, and then use PHP variables to replace the specific dynamic parts. </p> <p></p> <pre class="brush:php;toolbar:false"> <?php $out =<<<_END ..... _END; ?>
You can also use the above method to assign the contents of the two tags to variables.
Note: The _END tag used to close must be placed on a separate line, and no other content can be added to this line, even comments or spaces are not allowed
The above has introduced a brief discussion of the