javascript - PHP 删除 &(和)符号之后的所有内容

标签 javascript php encoding parameters

我的操作是:

var SimTxt = "some text & some other text";
...
xmlhttp.send(&SimTxt ="+SimTxt);
...

<?php 
$SimTxt = $_POST['SimTxt'];

echo

 <button id="btn9" class="sim_btn" type="button">
 '.$simBtn10.'
 </button>

但是屏幕上打印的只是“一些文本”,删除“&”符号后的所有内容

最佳答案

您的字符串需要在发送之前进行编码:

..
var SimTxt = encodeURIComponnent("some text & some other text");
xmlhttp.send(&SimTxt ="+SimTxt);
...

-- 字符串(实际上被视为参数,因此被 & 分割)不会被 PHP 视为 URI 组件。

关于javascript - PHP 删除 &(和)符号之后的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18956838/

相关文章:

javascript - window.setInterval 不起作用

javascript - 如何预加载声音文件并将其提供给 Flash 播放器?

c - 就地运行长度解码?

python - chardet 在 python 3 中运行不正确

javascript - 在 javascript+codeigniter 中分割数组值

javascript - 获取 "jQuery("a.raf_link").fancybox 不是函数"错误?

php - file_get_contents 从谷歌获取的文件与浏览器中显示的不同

php - 在不知道索引的情况下循环遍历 foreach

php - yii2 将同名输入插入数据库?

php - 将字符串拆分为带有瑞典字符的单词