The URL encoding function provided by php is byte-based, and cannot be used to encode data from the javascript function escape of ie. So here I share my php version's escapeunescape function functionescape ($ str) {preg_match_all ([x80-xff]. | [x01-x7f] +, $ str, $ r); $ ar $ r [0]; foreach ($
The URL encoding function provided by php is byte-based, and cannot be used to encode data from the javascript function escape of ie. Therefore, you can share your php version of escape/unescape function escape ($ str) {preg_match_all ("/[/x80-/xff]. | [/x01-/x7f] +/", $ str, $ r); $ ar = $ r [0]; foreach ($
URL encoding provided by phpFunctionIs byte-based.FunctionThe escape encoded data is powerless.
Therefore, I will share my php version of escape/unescape here.Function
Function escape ($ str ){
Preg_match_all ("/[/x80-/xff]. | [/x01-/x7f] +/", $ str, $ r );
$ Ar = $ r [0];
Foreach ($ ar as $ k => $ v ){
If (ord ($ v [0]) <128)
$ Ar [$ k] = rawurlencode ($ v );
Else
$ Ar [$ k] = "% u". bin2hex (iconv ("GB2312", "UCS-2", $ v ));
}
Return join ("", $ ar );
}
Function unescape ($ str ){
$ Str = rawurldecode ($ str );
Preg_match_all ("/(? : % U. {4}) |. +/", $ str, $ r );
$ Ar = $ r [0];
Foreach ($ ar as $ k => $ v ){
If (substr ($ v, 0, 2) = "% u" & strlen ($ v) = 6)
$ Ar [$ k] = iconv ("UCS-2", "GB2312", pack ("H4", substr ($ v,-4 )));
}
Return join ("", $ ar );
}