Php是什么<<<意思?

时间:2010-05-06 10:00:27

标签: 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;
}
?>

3 个答案:

答案 0 :(得分:5)

它被称为Heredoc syntax,可用于分配字符串值。

答案 1 :(得分:4)

Heredoc syntax中的字符串。

答案 2 :(得分:3)

这是另一种定义String的方法(Newdoc / Heredoc语法) - Manual - String