mb_check_encoding
Check whether the string is valid in the specified encoding
Function name: mb_check_encoding()
Applicable version: PHP 4 >= 4.0.6, PHP 5, PHP 7
Function description: mb_check_encoding() function is used to check whether a string is the specified character encoding.
Usage: bool mb_check_encoding ( string $var [, string $encoding = mb_internal_encoding() ] )
parameter:
Return value:
Example:
// 检查字符串是否是UTF-8 编码$str = "Hello, 世界!"; if (mb_check_encoding($str, "UTF-8")) { echo "字符串是UTF-8 编码"; } else { echo "字符串不是UTF-8 编码"; }
Output:
字符串是UTF-8 编码
Notes: