我正在阅读Google AnalyticsAPI文档,并注意到我之前从未见过/使用的语法:
<script>
<?php
<<<HTML
cxApi.setChosenVariation(
$chosenVariation, // The index of the variation shown to the visitor
$experimentId // The id of the experiment the user has been exposed to
);
HTML;
?>
</script>
<<<HTML
做了什么,这叫做什么?
答案 0 :(得分:4)
它被称为HEREDOC字符串。来自docs:
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
答案 1 :(得分:3)
那是PHP的heredoc。基本上它的工作原理如下:
<div>
<?php
echo <<<EOL
Write stuff here,
no need to worry about double " quotes or single ' quotes
Just write on.
When done end it like this:
EOL;
?>
</div>
答案 2 :(得分:3)
它称为heredoc语法。您可以在PHP网站here上查看。