mb_detect_order()

mb_detect_order() — Set/Get character encoding detection order.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Sets the automatic character encoding detection order to encoding.

Signature

mb_detect_order(array|string|null $encoding = null): array|bool

Parameters

ParameterTypeWhat it takes
$encodingarray|string|nullencoding is an array or comma separated list of character encoding. See supported encodings.

Return value

When setting the encoding detection order, true is returned on success or false on failure. When getting the encoding detection order, an ordered array of the encodings is returned.

Example

A runnable snippet:

/* Set detection order by enumerated list */ mb_detect_order("eucjp-win,sjis-win,UTF-8"); /* Set detection order by array */ $ary[] = "ASCII"; $ary[] = "JIS"; $ary[] = "EUC-JP"; mb_detect_order($ary); /* Display current detection order */ echo implode(", ", mb_detect_order());

Changelog

VersionChange
8.0.0encoding is nullable now.

See also

mb_internal_encoding(), mb_http_input(), mb_http_output(), mb_send_mail()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page mb_detect_order() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.