php style EOT EOD

来源:互联网 发布:mac版lol 编辑:程序博客网 时间:2024/05/17 03:36
<?php
    $str = <<<EOD
   this is some something will to be prite;
EOD;     // 不能有空格,不然会报错

     class foo{
        var $foo;
        var $bar ;

        function fun(){
             $this->foo = 'foo';
             $this->bar = Array('bar1','bar2','bar3');
        }
     }
     $foo = new foo();
     $name = 'zjl';


    echo <<<EOT
        My name is "$name"; I like $foo->foo;
        now i am priting something {$foo-> bar[2]};
        this should captal a 'A': \x41'
EOT;   // 不能有空格,不然会报错
?>


有空格-报错:
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\php\2tyle\str_eot.php on line 24


0 0
原创粉丝点击