2013-12-09 56 views
0

我想扔在一个html评论框中,我在站点上回显出的输出之一,但是当我尝试时没有出现。在php变量脚本

$output .= "<div id=\"HCB_comment_box\"><a href=\"http://www.htmlcommentbox.com\">HTML Comment Box</a> is loading comments...</div>"; 


$output .=" <script type=\"text/javascript\" language=\"javascript\" id=\"hcb\"> if(!window.hcb_user){hcb_user={ };} (function(){s==document.createElement(\"script\");s.setAttribute(\"type\",\"text/javascript\");s.setAttribute(\"src\", \"http://www.htmlcommentbox.com/jread?page=\"+escape((window.hcb_user && hcb_user.PAGE)||(\"\"+window.location)).replace(\"+\",\"%2B\")+\"&opts=470&num=10\");if (typeof s!=\"undefined\") document.getElementsByTagName(\"head\")[0].appendChild(s);})(); </script>"; 

事情是,第一个输出结果很好,但第二个输出结果真正的内容 - 没有。

请帮助我。


答案!

我自己找到答案。

之前

{S ==使用document.createElement(\ “脚本\”);

显然==破坏脚本,所以它应该是

{S =使用document.createElement(\ “脚本\”);不知道为什么,但它的工作。

现在我只需要弄清楚如何设计它,但我会自己解决这个问题!谢谢大家的快速回复!

$output .= "<div id=\"HCB_comment_box\"><a href=\"http://www.htmlcommentbox.com\">HTML Comment Box</a> is loading comments...</div>";

+3

“不出来罚款”?那是什么意思?向我们展示它生成的HTML。 – Joe

+0

是否有'echo $ output;'在任何地方?哪一个是“第一个”输出......两行都是同一个变量的一部分。 – Esaevian

+2

PHP本意是处理HTML - 写入原始HTML,并在需要时输入PHP w /''标签,不要通过转义引用破坏您的生活! – moonwave99

回答

-1

开始空即VAR,这样

$output = null; 
+0

什么会将'$ output'设置为null来完成?如果你想更好的初始化变量,把它转换为一个字符串而不是null(例如''output ='';')。 – user555

+0

@ user555这两个选项都是正确的,因为PHP是一种自适应语言,系统会将$输出转换为字符串。 – c42759