Home >Backend Development >PHP Tutorial >PHP delimiter generation of multi-line strings

PHP delimiter generation of multi-line strings

WBOY
WBOYOriginal
2016-07-28 08:26:122431browse

It is suitable for more complex strings, generating HTML strings or XML or other functions. It will treat each line as each line of text. However, in some special cases, it cannot be seen but the real existence, such as HTML code, will be ignored. Line break


Symbol:
<<<

Syntax:

<code><<<变量(无<span>$符</span>)
(开头无空格)第一行 
<span>XXX</span><span>XXX</span><span>XX</span>(开头无空格)变量(无<span>$符</span>)</code>
<code><span><span><?php</span><span>$s</span> =<span><<<s
<p>1</p>
<p>2</p>
<p>3</p>
s;<span>echo</span><span>$s</span>;
<span>?></span><pre class="brush:php;toolbar:false"><code>1

2

3</code>

Example 2:

<code><span><?php</span><span>$_data</span> =<span><<<data
<?xml version="1.0" encoding="UTF-8"?>
<note>
    <to>George</to>
    <from>老三</from>
    <heading>Reminder</heading>
    <body>Don't forget the meeting!</body>
</note>
data;</span><span>$myfile</span> = fopen(<span>"file.txt"</span>, <span>"w"</span>) <span>or</span><span>die</span>(<span>"Unable to open file!"</span>); 
fwrite(<span>$myfile</span>, <span>$_data</span>);
fclose(<span>$myfile</span>);
<span>?></span></code>
<code>file.txt内容:
<span><?xml version="1.0" encoding="UTF-8"?></span><span><<span>note</span>></span><span><<span>to</span>></span>George<span></<span>to</span>></span><span><<span>from</span>></span>老三<span></<span>from</span>></span><span><<span>heading</span>></span>Reminder<span></<span>heading</span>></span><span><<span>body</span>></span>Don't forget the meeting!<span></<span>body</span>></span><span></<span>note</span>></span></code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the generation of PHP delimiter multi-line strings, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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
Previous article:性能优化大全Next article:PHP入门7 静态属性的访问