为什么我无法在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