PHP in the search page, want to search the Chinese characters are also included in the URL, how to encode and decode, so that the URL can not see the Chinese characters, at the same time to achieve the purpose of the search.
Reply content:
PHP in the search page, want to search the Chinese characters are also included in the URL, how to encode and decode, so that the URL can not see the Chinese characters, at the same time to achieve the purpose of the search.
You can urlencode code multiple times, and you won't see it.
Processing Chinese characters using the UrlEncode function
Put it in a cookie ...
Find a solution on the Web:
function Myencode ($STR) {
$arrReturn=array();for($i=0;$i
='a'){//是字母 $arrReturn[]=chr(ord($char)+10); }else{ //是数字 //0->a,1->b,2->c ,3->d //即chr(ord($char)-ord('0')+ord('a')); //=chr(ord($char)-48+97) //=chr(ord($char+49) $arrReturn[]=chr(ord($char)+49); } }}return implode('',$arrReturn);
}
echo myencode (' Apple '). '
';//oiilljogjojm
function Mydecode ($STR) {
$chinese=array();for($i=0;$i
=107 ? chr(ord($char)-10):chr(ord($char)-49); } $chinese[]= chr(hexdec($arr[0].$arr[1]));}return implode('',$chinese);
}
echo mydecode (' OELNKAOFKFLN ');//Apple
?>