蓝山帝景
首先,所有的原因都是主观的。与其说这是原因,不如说是味道的问题。就我个人而言,我发现本文档非常无用,偶尔也会使用它,大多数时候我需要将一些HTML放入变量中,并且不想费心于输出缓冲,例如形成HTML电子邮件消息。格式化不符合一般的缩进规则,但我认为这不是什么大事。 //some code at it's proper level
$this->body = <<
heredoc text sticks to the left border
but it seems OK to me.HERE;
$this->title = "Feedback";
//and so on至于已被接受的答案中的例子,这只不过是作弊而已。字符串示例,实际上,如果不欺骗它们,则更简洁。$sql = "SELECT * FROM $tablename
WHERE id in [$order_ids_list]
AND product_name = 'widgets'";$x = 'The point of the "argument" was to illustrate the use of here documents';