<Operator in PHP
PHP provides the <operator to construct a multi-line string sequence, usually called here-document or abbreviated as heredoc.
This method details the literal value of a string and retains the underline and other spaces (including indentation) of the string in the text ). For example:
-
1 <?php2 $author ='wixy';3 echo <<<_END4 Thisis a Headline5 Thisis the first line.6 Thisis the second line.7 ---Writtenby $author.8 _END;9 ?>
The PHP parser outputs all the content in the middle of the two _ END labels, which is equivalent to a string referenced by double quotation marks. This means that we can write the entire HTML language directly in the PHP code, and then use the PHP variable to replace the specific dynamic part.
-
1 <?php2 $out =<<<_END3 .....4 _END;5 ?>
You can also assign the values of the two tags to the variables in this way. Note: The _ END label used to close must be placed on a single line, and other content cannot be added to this line, even if comments or spaces are not allowed.