Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将php插入javascript代码段_Javascript_Php - Fatal编程技术网

将php插入javascript代码段

将php插入javascript代码段,javascript,php,Javascript,Php,从我在搜索函数中读到的内容来看,javascript绝对需要。当我为discus_标识符和discus_标题加入示例vaiables时,这个脚本工作得很好,但是当我尝试使用存储在页面中的php变量时,它崩溃了 <div id="disqus_thread"></div> <script> var disqus_shortname = 'sample'; var disqus_config = function () { this.

从我在搜索函数中读到的内容来看,javascript绝对需要。当我为discus_标识符和discus_标题加入示例vaiables时,这个脚本工作得很好,但是当我尝试使用存储在页面中的php变量时,它崩溃了

<div id="disqus_thread"></div>
<script>
    var disqus_shortname = 'sample';

    var disqus_config = function () {
      this.page.remote_auth_s3 = '*********';
      this.page.api_key = '********';
}
</script>

<script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_identifier = "/posts/"<?php var_dump($postid); ?>;
       var disqus_title = <?php var_dump($title); ?>;

       /* * * DON'T EDIT BELOW THIS LINE * * */
       (function() {
         var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
       })();
</script>

<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

var Discus_shortname='样本';
var discus_config=函数(){
this.page.remote_auth_s3='***********';
this.page.api_key='********';
}
/***配置变量:粘贴到网页前编辑***/
var discus_identifier=“/posts/”;
var Discus_title=;
/***请勿在此行下方编辑***/
(功能(){
var dsq=document.createElement('script');dsq.type='text/javascript';dsq.async=true;
dsq.src='/'+discus_shortname+'.discus.com/embed.js';
(document.getElementsByTagName('head')[0]| | document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
请启用JavaScript以查看
var_dump()不是您想要的,因为它“转储有关变量的信息”,而不仅仅是回显内容。()您希望获取$postid并呈现变量中包含的文字字符串

使用



相反

如果需要字符串文字而不是int表示,还需要用引号括起来,所以

var post_id = "<?=$post_id?>";
var post_id=”“;
会起作用还是

var post_id = "This <?=$post_id?> is great";
var post\u id=“这太棒了”;
var_dump()不是您想要的,因为它“转储有关变量的信息”,而不仅仅是回显内容。()您希望获取$postid并呈现变量中包含的文字字符串

使用



相反

如果需要字符串文字而不是int表示,还需要用引号括起来,所以

var post_id = "<?=$post_id?>";
var post_id=”“;
会起作用还是

var post_id = "This <?=$post_id?> is great";
var post\u id=“这太棒了”;
var_dump()不是您想要的,因为它“转储有关变量的信息”,而不仅仅是回显内容。()您希望获取$postid并呈现变量中包含的文字字符串

使用



相反

如果需要字符串文字而不是int表示,还需要用引号括起来,所以

var post_id = "<?=$post_id?>";
var post_id=”“;
会起作用还是

var post_id = "This <?=$post_id?> is great";
var post\u id=“这太棒了”;
var_dump()不是您想要的,因为它“转储有关变量的信息”,而不仅仅是回显内容。()您希望获取$postid并呈现变量中包含的文字字符串

使用



相反

如果需要字符串文字而不是int表示,还需要用引号括起来,所以

var post_id = "<?=$post_id?>";
var post_id=”“;
会起作用还是

var post_id = "This <?=$post_id?> is great";
var post\u id=“这太棒了”;
var discus_title=“;
那里有一个无关的引用
var discus_title=“那里有一个无关的引用
var discus_title=“;
那里有一个无关的引用
var discus_title=“那里有一个无关的引用