Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.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
JQuery和PHP不打印&;amp;_Php_Jquery_Wordpress - Fatal编程技术网

JQuery和PHP不打印&;amp;

JQuery和PHP不打印&;amp;,php,jquery,wordpress,Php,Jquery,Wordpress,有人能告诉我如何处理这种情况吗 我使用PHP和JQuery一起创建一个带有参数的新url。然而,它并没有在url中输入符号,而是“38;”。浏览器不会读取我的第二个参数。我还尝试过使用“&;”(不显示在SO上),它创建了字面上的回声,简单“&”也产生了html代码“\$”>hex“&&&>htmlhtml 如何获取脚本来创建& 我在wordpress平台上以文本模式工作 这是我在使用“&naam”时得到的结果: 编码: echo "<script>

有人能告诉我如何处理这种情况吗

我使用PHP和JQuery一起创建一个带有参数的新url。然而,它并没有在url中输入符号,而是“38;”。浏览器不会读取我的第二个参数。我还尝试过使用“&;”(不显示在SO上),它创建了字面上的回声,简单“&”也产生了html代码“\$”>hex“&&&>htmlhtml

如何获取脚本来创建&

我在wordpress平台上以文本模式工作

这是我在使用“&naam”时得到的结果:

编码:

echo "<script>  
            $(function() {
                $('.checked').click(function(e) {
                        e.preventDefault();
                        var dialog = $('<strong>Wat is jou RSVP keuse?</strong>').dialog({
                            buttons: {
                                \"Ja\": function() {
                                            window.location.href = \"http://hannelliemarcel.co.za/rsvp-ja?email=" . $Email . "&naam=" . $Naam . "\";
                                        },
                                \"Nee\":  function() {
                                            window.location.href = \"http://hannelliemarcel.co.za/rsvp-nee?email=" . $Email . "&naam=" . $Naam . "\";
                                        },
                                \"Kanselleer\":  function() {
                                    dialog.dialog('close');
                                }
                            }
                        });
                    });
                });
        </script>";
echo”
$(函数(){
$('.checked')。单击(函数(e){
e、 预防默认值();
var dialog=$(“Wat是jou RSVP keuse吗?”)。dialog({
按钮:{
\“Ja\”:函数(){
window.location.href=\”http://hannelliemarcel.co.za/rsvp-ja?email=“$Email.”&naam=“.$naam.”\”;
},
\“Nee\”:函数(){
window.location.href=\”http://hannelliemarcel.co.za/rsvp-nee?email=“$Email.”&naam=“.$naam.”\”;
},
\“Kanselleer\”:函数(){
dialog.dialog('close');
}
}
});
});
});
";

我能够通过使用encodeURI()来解决这个问题;函数使用参数化URL

而不是使用符号&;的HTML代码;,我使用了符号的UTF-8格式,即\u0026。这是一种更安全的字符编码方式

那么它应该是这样的:

<script>
  function createAmp(){
    var symb = encodeURI('\u0026');
    document.getElementById('contentArea').innerHTML = "http://example.com/foo?id=123" + symb + "name=john";
  }
</script>

函数createAmp(){
var symb=encodeURI('\u0026');
document.getElementById('contentArea')。innerHTML=”http://example.com/foo?id=123“+symb+”name=john”;
}

感谢大家在评论中的建议,特别是@milz.

——这是您的预期结果?如果您只使用window.location.href=\\“”,对我来说效果很好$电子邮件“&naam=”$纳姆。"\"; 1安培刚刚试过,但还是写了38美元;。用屏幕截图更新了原始问题。为什么有
“&&naam=“
”?请尝试
“&naam=“
”&;naam=“
”。使用UTF-8编码的脚本,而不是使用巨大的echo标记,为什么不结束PHP标记,输出
标记,然后在它之后启动另一个PHP标记?这样你就不必逃避所有的引用。