PHP is an environment, a server software, and a descriptive programming language. Since the birth of PHP in 1994, PHP has become one of the most popular programming languages for many years: many well-known websites we can see are using PHP to develop their own websites, including Baidu and Google. The most popular open-source website application wor
PHP is an environment, a server software, and a descriptive programming language. Since the birth of PHP in 1994, PHP has become one of the most popular programming languages for many years: many well-known websites we can see are using PHP to develop their own websites, including Baidu and Google. The most popular open-source website application wor
PHP is an environment, a server software, and a descriptive programming language. Since the birth of PHP in 1994, PHP has become one of the most popular programming languages for many years: many well-known websites we can see are using PHP to develop their own websites, including Baidu and Google. Wordpress, the most popular open-source website program, is also developed based on PHP. We should note that 60% of the world's websites are developed using wordpress, which means that, at least 60% of websites are PHP-based. After talking about PHP, we have to talk about PHP Data Processing. Most of the codes we usually use are UTF8 or ANSI. In fact, websites of different languages have their own codes, that is to say, there may be many types of codes in the world. The encoding of our database must be consistent with that of the webpage. Otherwise, an error will occur. Therefore, it is very important to identify the encoding when processing strings.
Function Format
The format of mb_detect_encoding is string mb_detect_encoding (string $ str [, mixed $ encoding_lis = mb_detect_order () [, bool $ strict = false]). This means that the mb_detect_encoding function will return a string value with three parameters:
- The first parameter is a required string;
- The second parameter is an optional parameter, and encoding_list is an encoding list. If this parameter is omitted, the value returned by the mb_detect_order () function is called as the parameter;
- The third parameter is a Boolean parameter, which determines whether to strictly detect string encoding. The default value is false.
Usage
??
From the code, we can see that this function is very easy to use. What do you think.
It is worth noting that the mb_detect_encoding function is added only in versions 4.0.6 and later (including 4.0.6). If your PHP version is earlier than 4.0.6, what will happen? You should know !!
Statement: This article uses BY-NC-SA protocol for authorization | IT passers-
Reprinted please note