<< in PHP

Source: Internet
Author: User
<< Available in PHP <运算符构建多行字符串序列的方法,通常称为here-document或表示为heredoc的简写。< p>

This method details the literal value of the string and preserves the underscore and other spaces (including indentation) of the string in the text. For example:

            PHP2$author = ' Wixy '; 3 echo <<<_end4thisis a headline5 thisis the first line. 6 Thisis the second line. 7 $author. 8 _end; 9 ?>

The PHP parser outputs all the content in the middle of the two _end tags, which is equivalent to a string quoted in double quotes.

This means that we can write an entire HTML language directly into the PHP code, and then replace the specific dynamic parts with PHP variables.

            PHP2$out =<<<_end3 ..... 4 _end; 5 ?>

You can also assign the contents of two tags to a variable in this way.

Note : The _end tag that is used to close must be placed on a single line, and no other content can be added to this line, even if comments or spaces are not allowed

The above describes the << in PHP<>

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.