前端encodeURIComponent 和后端http_build_query配合
Posted Loweringye
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了前端encodeURIComponent 和后端http_build_query配合相关的知识,希望对你有一定的参考价值。
解决特殊字符不能转义
1、
function fixedEncodeURIComponent (str) {
return encodeURIComponent(str).replace(/[!‘()*]/g, function(c) {
return ‘%‘ + c.charCodeAt(0).toString(16);
});
}
return encodeURIComponent(str).replace(/[!‘()*]/g, function(c) {
return ‘%‘ + c.charCodeAt(0).toString(16);
});
}
2、
http_build_query($array,‘‘,‘&‘,php_QUERY_RFC3986);
以上是关于前端encodeURIComponent 和后端http_build_query配合的主要内容,如果未能解决你的问题,请参考以下文章