$v..." />
escape unescape的php下的实现方法
escape unescape的php下的实现方法
发布时间:2016-12-29 来源:查字典编辑
摘要:functionescape($str){preg_match_all("/[x80-xff].|[x01-x7f]+/",$str,$r)...

functionescape($str){

preg_match_all("/[x80-xff].|[x01-x7f]+/",$str,$r);

$ar=$r[0];

foreach($aras$k=>$v){

if(ord($v[0])<128)

$ar[$k]=rawurlencode($v);

else

$ar[$k]="%u".bin2hex(iconv("GB2312","UCS-2",$v));

}

returnjoin("",$ar);

}

functionunescape($str){

$str=rawurldecode($str);

preg_match_all("/(?:%u.{4})|.+/",$str,$r);

$ar=$r[0];

foreach($aras$k=>$v){

if(substr($v,0,2)=="%u"&&strlen($v)==6)

$ar[$k]=iconv("UCS-2","GB2312",pack("H4",substr($v,-4)));

}

returnjoin("",$ar);

}

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类