在以下代码中来自 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/