The PHP Function MB_Detect_Order
The php function mb_detect_order is an inbuilt function that is utilized to set or get the character encoding detection order. This function accepts one parameter i.e encoding. This function returns an array when getting the encoding detection order and it return true when setting encoding detection order.
Most existing PHP applications are written using single byte encodings and are not prepared for multibyte environments. The problem is that standard string functions like substr() and str_replace() may not correctly translate multibyte characters to single byte chars in some cases. mbstring provides multibyte specific string functions that can be used to solve these problems and it also includes function overloading so that you can easily add support for multibyte encodings to existing applications without modifying the code.
mb_detect_order can be used to set the detection order for mbstring and for all other string processing functions that utilize it. The order is important because it determines which encodings will be checked for multibyte sequences. If mb_detect_order detects that a string is not in UTF-8, it will try to convert the string to utf-8 even if the bytes do not match. This behavior can lead to incorrect results.
mb_detect_order sets the default to UTF-8 which works well in most situations but it's possible to use the function to set other internal encodings that don't cause problems with PHP. These encodings include ISO-8859-1, BIG5, CP936, GB18030 and SJIS. These encodings should not be used in the application itself but they can be useful for converting input/output to and from these encodings.