echo<<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some{$foo->bar[1]}.
This should printing a capital 'A':\x41
EOT;上面的这段好象里面不能用变量.
改后的如下.我试了好用.

echo "T My name is ".$name." I am printing some ".$foo->foo." Now, I am rinting some{".$foo->bar[1]."} This should printing a capital 'A':\x41 ";

解决方案 »

  1.   

    <?php
    $str = <<<EOD
    Example of string
    spanning multiple lines
    using heredoc syntax.
    EOD;/*More complex example, with variables.*/
    class foo {
      var $foo;
      var $bar;  function foo(){
        $this->foo = 'Foo';
        $this->bar = array('Bar1','Bar2','Bar3');
      }
    }$foo = new foo();
    $name = 'MyName';echo <<<EOT   
    My name is "$name". I am printing some $foo->foo.
    Now, I am printing some{$foo->bar[1]}.
    This should printing a capital 'A':\x41
    EOT;
    ?>
      

  2.   

    各位谁能帮忙解释一下下面这句话的意思呀?
    我值的不是里面类以及函数等的调用,
    而是 echo <<<EOT 这一部分是什么意思?为什么可以这样用?
    echo <<<EOT   
    My name is "$name". I am printing some $foo->foo.
    Now, I am printing some{$foo->bar[1]}.
    This should printing a capital 'A':\x41
    EOT;
    谢谢了:)