The mb_detect_order() function in PHP can be used to set/get character encoding detection in order. This function is supported in PHP 4.2.0 or higher.
array|bool mb_detect_order(str $encoding)
mb_detect_order()Accepts only one parameter $encoding, which can be a string , Array or Boolean value.
$encoding− The encoding parameter can be an array or a comma-separated list of character encodings. If omitted or null, returns an array in the current character encoding detection order.
When setting the encoding detection sequence, True is returned on success and False on failure.
Demonstration
<?php // Set detection order by enumerated list mb_detect_order("eucjp-win,sjis-win,UTF-8"); // Set detection order by array $array[] = "ASCII"; $array[] = "JIS"; $array[] = "EUC-JP"; mb_detect_order($array); // It shows the current detection order echo implode(", ", mb_detect_order()); ?>
ASCII, JIS, EUC-JP
The above is the detailed content of PHP - How to set character encoding detection order using mb_detect_order() function?. For more information, please follow other related articles on the PHP Chinese website!