我的操作是:
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/