Home > Backend Development > PHP Tutorial > <<< operator in PHP, operator in php_PHP tutorial

<<< operator in PHP, operator in php_PHP tutorial

WBOY
Release: 2016-07-12 08:53:55
Original
964 people have browsed it

The <<< operator in PHP, the operator in PHP

PHP provides the <<< operator to construct a multi-line string sequence Method, often called a here-document or expressed as abbreviation for 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:
  1. <span>1</span> <?<span>php
    </span><span>2</span> <span>$author</span> ='wixy'<span>;
    </span><span>3</span> <span>echo</span> <<<<span>_END
    </span><span>4</span> <span>Thisis a Headline
    </span><span>5</span> Thisis the first line.
    <span>6</span> Thisis the second line.
    <span>7</span> ---Writtenby <span>$author</span>.
    <span>8</span> <span>_END;
    </span><span>9</span> ?>
    Copy after login
The PHP parser will output everything between the two _END tags, which is equivalent to a string quoted with double quotes. 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.
  1. <span>1</span> <?<span>php
    </span><span>2</span> <span>$out</span> =<<<<span>_END
    </span><span>3</span> .....
    <span>4</span> <span>_END;
    </span><span>5</span> ?>
    Copy after login
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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1122392.htmlTechArticlePHP中的运算符,php中运算符 PHP中提供了运算符构建多行字符串序列的方法,通常称为here-document或表示为heredoc的简写。 这种方法详细表述了...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template