PHP定界符


字符串 被按照 该脚本文件 相同的 编码方式来编码
Nowdoc 结构是类似于单引号字符串的
nowdoc 中不进行解析操作
这种结构很适合用于 嵌入 PHP 代码 或 其它大段文本
而无需对其中的特殊字符进行转义

//php.net/manual/zh/language.types.string.php

PHP定界符 多行字符串的生成
$_data =<<<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;
$myfile = fopen("file.txt", "w") or die("Unable to open file!");
fwrite($myfile, $_data);
fclose($myfile);


file.txt内容:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>George</to>
<from>老三</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>