PHP transform file encoding is a relatively simple thing, but sometimes, when transferring Chinese parameters in development, sometimes it doesn't know what code is, which results in the phenomenon of garbled.There is a very convenient solution here to automatically identify the code and convert it to UTF-8.The specific code is as follows:

复制代码代码如下:功能characet($数据){
如果(!空($)){
$fileType = mb_detect_encoding ($data, array ('UTF-8','GBK','LATIN1','BIG5'));
如果($文件类型!= 'utf-8){
数据mb_convert_encoding美元(美元的数据,美元'utf-8,文件类型);
}
}
返回$数据;
}