PHP100分享php三目文本定界符

分享php三目文本定界符
// 三目定界符; 可以用它定义长段的文本,然后分割成数组,应用,很好的啊,自由发挥吧;
$string = <<< EOT
        Example of strings spanning multiple lines,
        using heredoc syntax,c
            using heredoc, syntax,b
                using heredoc syntaxa
EOT;
//结束定界符必须顶格写; 定界符 后的EOT 是自己定义的,可以是任意的
$arr=explode("\n",$string);
print_r($arr);//Array ( [0] => Example of strings spanning multiple lines [1] => using heredoc syntax
//[2] => c using heredoc [3] => syntax [4] => b using heredoc syntaxa )
echo $string;//Example of strings spanning multiple lines,
//using heredoc syntax,c using heredoc, syntax,b using heredoc syntaxa

http://bbs.cit.cn/read-htm-tid-15617.html

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Grow your business fast with

Suku