如果您使用 javascript 的 encodeURI()
方法对某些内容进行编码,您如何在 PHP 中获取解码后的字符串?
我有字符串 name= "salman mahmood"
,我正在通过 POST 消息将其发送到我的服务器。当我 alert()
客户端的字符串时,它在编码后给我“salman%20mahmood”。
在服务器端,我使用 urldecode()
对其进行解码,但我得到的结果是“salman”。我需要不同的解码方法吗? rawurldecode
也不起作用;我只需要恢复空间的值。
编辑:感谢大家的建议,但是我写了如下代码,但还是不行!!
<input type="text" id="chapterNumber" value=<?php echo rawurldecode("chapter%20Two"); ?> disabled="disabled">
它只打印“章节”
最佳答案
把它放在引号里 ' '
<input type="text" id="chapterNumber" value='<?php echo rawurldecode("chapter%20Two"); ?>'disabled="disabled">
关于php - 如何解码使用 encodeUri() 编码的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6981824/