首頁 >後端開發 >php教程 >PHP定界符 多行字串的生成

PHP定界符 多行字串的生成

WBOY
WBOY原創
2016-07-28 08:26:122437瀏覽

適用於比較複雜的字串、產生HTML字串或XML 或其他作用,他會把每一行當作文字的每一行.但是在一些特殊情況下看不出來但是真正的存在,比如HTML程式碼,會無視換行符


符號:
語法:
<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></code>
<code>1

2

3</code>

實例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); }); });

以上就介紹了 PHP定界符 多行字串的生成,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn