<<< 是什么意思?

标签 php syntax

在以下代码中来自 http://us2.php.net/manual/en/language.oop5.properties.php <<< 符号是什么意思?

<?php
class SimpleClass
{
   // invalid property declarations:
   public $var1 = 'hello ' . 'world';
   public $var2 = <<<EOD
hello world
EOD;
   public $var3 = 1+2;
   public $var4 = self::myStaticMethod();
   public $var5 = $myVar;

   // valid property declarations:
   public $var6 = myConstant;
   public $var7 = array(true, false);

   // This is allowed only in PHP 5.3.0 and later.
   public $var8 = <<<'EOD'
hello world
EOD;
}
?>

最佳答案

它叫做 Heredoc syntax并可用于分配字符串值。

关于<<< 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2780160/

相关文章:

php - Javascript AJAX 登录没有行为

php - 只有某些文本会插入数据库

php - Jquery 和 Ajax 中的错误

azure - 从 Terraform 中的 map 列表中输出特定值

php - CodeIgniter - 重定向()到另一个页面的方法,带有额外的字符串以输出为 html?

javascript - 使用 Javascript/PHP : Trying to display background image - logic wrong?

python - 如何在 Python 中嵌套单行语句?

perl - 一行简洁的 foreach 表达式

Ruby - 意外的 tIDENTtifier,期待 $end

c++ - 为什么 C++ 模板参数应该声明为类类型?