如果我想说
Hello
World
,建议使用'
(撇号)或"
(引号)?
例:
<?php
$apostrophe = 'Hello' . "'n" . 'World!';
$quotation_mark = "Hello'nWorld!";
$newline = 'Hello
World!';
echo (($apostrophe == $quotation_mark) && ($apostrophe == $newline));
输出:1
(真)
你怎么看这个
$text = 'Hello' . PHP_EOL
. 'World!';
在我看来,这很好读配额标记之间的区别很容易。带有双配额标记的字符串将解析为变量和特殊值,而另一个则不分析。