Home >Backend Development >PHP Tutorial >How does php read the encoding of text?
This article mainly introduces the relevant information about the encoding of PHP detection text. Friends who need it can refer to it
Judge whether it belongs to the encoding by a loop encoding of the text. .
public function chkCode($string) { $code = array( 'ASCII', 'GBK', 'UTF-8' ); foreach ($code as $c) { if ($string === iconv('UTF-8', $c, iconv($c, 'UTF-8', $string))) { return $c; } } return null; }
The above is the detailed content of How does php read the encoding of text?. For more information, please follow other related articles on the PHP Chinese website!