PHP determines what encoding the variable content is (gbk? utf-8) mb_detect_encoding
Release: 2023-02-28 20:06:01
Original
2600 people have browsed it
mb_detect_encoding($str,"UTF-8, ISO-8859-1, GBK"); Get the encoding type
function convToUtf8($str) {
if( mb_detect_encoding($str,"UTF-8, ISO-8859-1, GBK")!="UTF-8" ) {//判断是否不是UTF-8编码,如果不是UTF-8编码,则转换为UTF-8编码
return iconv("gbk","utf-8",$str);
} else {
return $str;
}
} Copy after login
Copy code
|
Statement of this Website
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
Latest Articles by Author
-
2018-06-30 16:21:47
-
2023-03-15 12:22:02
-
1970-01-01 08:00:00
-
2023-02-28 17:52:02
-
2023-02-28 15:12:01
-
1970-01-01 08:00:00
-
2019-02-22 15:16:56
-
2023-02-28 16:28:01
-
2023-03-25 19:14:01
-
1970-01-01 08:00:00