Friday, April 25, 2014

[PHP] 簡單介紹 Heredoc 定界符 的用法(連續三個小於符號 "<<<" )

有時候會在 php 程式碼中看到
$html = <<<eot
<span>hello</span>
eot;
echo $html;
這樣會印出 hello ,這邊的 eot 是可以替換的,例如
$html = <<<heredoc
<span>hello</span>
heredoc;
echo $html;
只要前後一致就好了。

No comments:

Post a Comment