How to convert gb2312 to utf8 in php
This article introduces how to convert gb2312 to utf8 in php, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Php gb2312 to utf8 conversion methods: 1, open the corresponding PHP file; 2, check the original code; 3, by using preg_replace and iconv functions to convert gb2312 pages to utf8 pages.
This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.
How to convert php gb2312 to utf8?
Convert PHP gb2312 pages to utf8 pages
Two functions, preg_replace and iconv, are used
$html = preg_replace ('/ charset=gb2312/', 'charset=UTF8', $html); / / $enc = mb_detect_encoding ($html); $html = iconv (' gbk', 'utf-8', $html)
Https://php.net/manual/en/function.iconv.php
Https://www.php.net/manual/en/function.preg-replace.php
Refer to the example on the official website of php
Example # 2 Using indexed arrays with preg_replace () Example # 1 iconv () example
* testurl.php