我需要用Javascript编码一个字符串,并想用PHP解码(下面的代码)。PHP/JavaScript:如何最好地编码/解码字符串?
不幸的是像urlencode()
,encodeURIComponent()
,等常用功能也不会在这种情况下工作,因为我的PHP框架解释斜线/
作为分隔符,即使是那些编码。
字符串长度在1到50个字符的范围内。加密不是重点,而是性能。
有谁知道base64
的好替代品吗?
的Javascript
var str = doEncode("I'm a String with special chars!§$%&/()");
window.location = "http://localhost/script.php?encoded_string=" + str;
PHP
$str = doDecode($_GET["encoded_string"]);
echo $str; // I'm a String with special chars!§$%&/()
提前感谢!
解决方案:*修复*“PHP框架”。你解决了一个不需要存在的问题。 – user2864740