Home >Backend Development >PHP Tutorial >PHP delimiter generation of multi-line strings
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.