爲什麼我無法在PHP heredoc中結束JavaScript?</script> in PHP heredoc
下面這行代碼的其餘部分:
</script>
變得不是PHP代碼部分。他們成爲HTML代碼。
這就像結束腳本代碼結束PHP塊。
$headerContent = <<<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>$title</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
<script>
</script> // Here is the problem
</head> // code here and below becomes not part of PHP.
<body>
.
.
.
HEAD;
解決這個問題的任何提示?
輸出是什麼樣的? – 2013-03-09 11:13:36
它是相同的*問題* [這裏](http://codepad.viper-7.com/T702GS)? – j0k 2013-03-09 11:14:06
@ j0k看起來不像有問題。添加'htmlentities()'看起來像是有效的。 http://codepad.viper-7.com/blvIDG – 2013-03-09 11:19:43