Home > Backend Development > PHP Tutorial > PHP - How to set character encoding detection order using mb_detect_order() function?

PHP - How to set character encoding detection order using mb_detect_order() function?

WBOY
Release: 2023-09-01 20:46:02
forward
1093 people have browsed it

PHP - 如何使用mb_detect_order()函数设置字符编码检测顺序?

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.

Syntax

array|bool mb_detect_order(str $encoding)
Copy after login

Parameters

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.

Return value

When setting the encoding detection sequence, True is returned on success and False on failure.

Example

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());
?>
Copy after login

Output

ASCII, JIS, EUC-JP
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template