php强制转换为UTF-8

  sre

5fd0dd9d1070e5200.jpg_fo742.png
/**
* 判断字符串是不是utf8 如果不是转成 utf8
*@param string vector
*@return string
vector
*
*/

function strToUtf8 (vector)
{
from_chr= mb_detect_encoding(vector,array('UTF-8','ASCII','EUC-CN','CP936','BIG-5','GB2312','GBK'));
if(
from_chr !="UTF-8")
{
vector = mb_convert_encoding(vector,'UTF-8',array('UTF-8','ASCII','EUC-CN','CP936','BIG-5','GB2312','GBK'));
}
return $vector;
}

LEAVE A COMMENT

Captcha Code