代码之家  ›  专栏  ›  技术社区  ›  Tegra Detra

php<<是什么意思?

  •  6
  • Tegra Detra  · 技术社区  · 15 年前

    在以下代码中 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 回复  |  直到 12 年前
        1
  •  5
  •   Tatu Ulmanen    15 年前

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

        2
  •  4
  •   kennytm    15 年前

    一根绳子 Heredoc syntax .

        3
  •  3
  •   Crozin    15 年前

    这只是定义字符串的另一种方法(newdoc/heredoc语法) Manual - String

    推荐文章