Home > Backend Development > PHP Tutorial > PHP function to get the encoding format of a string

PHP function to get the encoding format of a string

WBOY
Release: 2016-07-25 08:58:25
Original
2716 people have browsed it
  1. $encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2312′,"GBK",'BIG5′));
  2. echo $encode;
Copy code

Now you know what encoding format it is.

In addition, if you want to transcode it, you can refer to the following code:

  1. if ($encode == “UTF-8″){
  2. $string = iconv("UTF-8″,"GBK",$string);
  3. }
Copy code

Related The format of PHP file or string encoding involves a wide range of content. Programmer’s Home will introduce it in detail later. Let me introduce these today, I hope it can help everyone. Articles you may be interested in: Learn PHP string encoding conversion and judgment Example of PHP function to determine whether string encoding is utf8 Two methods for php to determine character encoding php automatically detects content encoding and converts code Function that automatically detects encodings in content and converts them php encoding conversion function (automatic character set conversion supports array conversion) php function iconv to change encoding



source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template