php decode javascript escape的函数

php的urldecode只能decode javascript的encodeURI,不能decode javascript的escape,下边的函数是万能的

   

function utf8_urldecode($str) {
      if(strpos('+'.$str,'%u')>0)
      {
          $str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
          return html_entity_decode($str,null,'UTF-8');;          
      }elseif(strpos('+'.$str,'%'))
      {
          return urldecode($str);
      }else
      {
          return $str;
      }

    }


你可能感兴趣的:(JavaScript,html,PHP,function,null)