我正在學習用戶手冊中的php。現在我在看下面的代碼:可以不正確的縮進打破php代碼?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?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 print a capital 'A': \x41
EOT;
?>
</body>
</html>
正如該代碼運行正常和輸出:我的名字是「MYNAME」。我正在打印一些Foo。現在,我正在打印一些Bar2。這應打印一資「A」:一個
當我試圖縮進PHP,使其在身體前方標記下它被註釋掉鉻broswer的HTML顯示錯誤:
解析錯誤:語法錯誤,C:\ xampp \ htdocs \ xampp \ phpnotes \ index.php中的文件意外結束,第39行
++ 1用於識別引起這個問題的規則。如果只有OP只是閱讀他使用的語言功能的文檔... – 2014-11-22 18:17:03
我從來沒有讀過一個正式的語言文檔,用於所有用於魯莽放棄的if語句。沒有時間RTFM的一切:) – STW 2014-11-22 18:21:28
@STW:如果你寫一個'if'語句,它不起作用,那麼你應該絕對RTFM。沒有煩惱這麼做 - 特別是在浪費某人_else's_時間問這個問題 - 只是在進攻性的懶惰! – 2014-11-22 18:30:37