文学常识题库

试试这段代码吧,解码mime的-PHP代码-PHP教程-幽默笑话

  • 作者:本站
  • 时间:2019-07-10
  • 132人已阅读
您现在的位置:首页 > 西方文学 > 文章
简介 文章内容试试这段代码吧,解码mime的修改时间:[2011/05/1021:38]阅读次数:[893]发表者:[起缘]functiondecode_mime_string($string){$

试试这段代码吧,解码mime的-PHP代码-PHP教程-幽默笑话

文章内容试试这段代码吧,解码mime的修改时间:[2011/05/1021:38]阅读次数:[893]发表者:[起缘]functiondecode_mime_string($string){$pos=strpos($string,=);if(!is_int($pos)){return$string;}$preceding=substr($string,0,$pos);//saveanyprecedingtext$search=substr($string,$pos+2,75);/*themimeheaderspecsaysthisisthelongestasingleencodedwordcanbe*/$d1=strpos($search,);if(!is_int($d1)){return$string;}$charset=substr($string,$pos+2,$d1);$search=substr($search,$d1+1);$d2=strpos($search,);if(!is_int($d2)){return$string;}$encoding=substr($search,0,$d2);$search=substr($search,$d2+1);$end=strpos($search,=);if(!is_int($end)){return$string;}$encoded_text=substr($search,0,$end);$rest=substr($string,(strlen($preceding.$charset.$encoding.$encoded_text)+6));switch($encoding){caseQ:caseq:$encoded_text=str_replace(_,%20,$encoded_text);$encoded_text=str_replace(=,%,$encoded_text);$decoded=urldecode($encoded_text);if(strtolower($charset)==windows-1251){$decoded=convert_cyr_string($decoded,w,k);}break;caseB:caseb:$decoded=urldecode(base64_decode($encoded_text));if(strtolower($charset)==windows-1251){$decoded=convert_cyr_string($decoded,w,k);}break;default:$decoded==.$charset..$encoding..$encoded_text.=;break;}return$preceding.$_mime_string($rest);}//decode_mime_string()。

Top