Home > Backend Development > PHP Tutorial > php搜索分页的问题

php搜索分页的问题

WBOY
Release: 2016-06-06 20:21:13
Original
1248 people have browsed it

PHP在搜索分页时,想将搜索的汉字也带在url里面,请问如何编码和解码,使得在url看不到汉字,同时达到搜索的目的。

回复内容:

PHP在搜索分页时,想将搜索的汉字也带在url里面,请问如何编码和解码,使得在url看不到汉字,同时达到搜索的目的。

你可以多次urlencode编码,那就看不到了

使用urlencode函数处理汉字

放在cookie里面...

在网上找到一个解决方案:
function myEncode($str){

<code>$arrReturn=array();
for($i=0;$i<strlen ascii for if>='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);</strlen></code>
Copy after login

}
echo myEncode('苹果').'
';//oiilljogjojm

function myDecode($str){

<code>$chinese=array();
for($i=0;$i<strlen for ord>=107 ? chr(ord($char)-10):chr(ord($char)-49);
    }
    $chinese[]= chr(hexdec($arr[0].$arr[1]));
}
return implode('',$chinese);</strlen></code>
Copy after login

}
echo myDecode('oelnkaofkfln');//苹果
?>

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template