Home >Web Front-end >JS Tutorial >PHP implementation code of escape and unescape functions in js_javascript skills

PHP implementation code of escape and unescape functions in js_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:09:181111browse

    
function phpescape($str)
{
$sublen=strlen($str);
$retrunString="";
for ($i=0;$i                                                                                               $tmpString=bin2hex(iconv("gb2312","ucs-2",substr ($str,$i,2)));
                                                                                                                                                                                 ​$retrunString.="%u".$tmpString;
                                              runString.="%".dechex(ord($str[$i]));
                                                                                                               🎜> preg_match_all("/%u.{ 4}|.{4};|d ;|. /U",$str,$r);
$ar = $r[0];
foreach($ar as $ k=>$v) {
If(substr($v,0,2) == "%u")
$ar[$k] = iconv("UCS-2","GBK", pack ("h4", substr ($ v, -4));
Elseif (Substr ($ v, 0,3) == "")
$ AR [$ k] = iconvvvvvvvvvv ("UCS-2","GBK",pack("H4",substr($v,3,-1)));
         elseif(substr($v,0,2) == "" ) {
                                   $ar[$k]                                                               }
return join("",$ar);
}
?>

Statement:
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