我正在从用户手册学习php。现在我正在查看以下代码:
Untitled Document$str = <<
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 <<
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
?>
此代码按预期运行并输出:我的名字是&#34; MyName&#34;。我正在打印一些Foo。现在,我正在打印一些Bar2。这应该打印一个大写&#39; A&#39;:A
当我尝试缩进php以使其位于body标签前面时,其下方的HTML会被注释掉chrome broswer显示错误:
解析错误:语法错误,第39行的C:\ xampp \ htdocs \ xampp \ phpnotes \ index.php中的文件意外结束