Multibyte mb_detect_order

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_detect_order — 문자 인코딩 감지 순서 설정/가져오기


설명

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

자동 문자 인코딩 감지 순서를 encoding으로 설정합니다.


매개변수

encoding
encoding은 배열 또는 쉼표로 구분된 문자 인코딩 목록입니다. 지원되는 인코딩을 참조하십시오.

encoding이 생략되거나 null이면 현재 문자 인코딩 감지 순서를 배열로 반환합니다.

이 설정은 mb_detect_encoding()mb_send_mail()에 영향을 줍니다.

mbstring은 현재 다음 인코딩 감지 필터를 구현합니다. 다음 인코딩에 대해 잘못된 바이트 시퀀스가 ​​있는 경우 인코딩 감지에 실패합니다.

UTF-8, UTF-7, ASCII, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP ISO-8859-*의 경우 mbstring은 항상 ISO-8859-*로 감지합니다.

UTF-16, UTF-32, UCS2 및 UCS4의 경우 인코딩 감지가 항상 실패합니다.


반환 값

인코딩 감지 순서를 설정할 때 성공하면 true를, 실패하면 false를 반환합니다.

인코딩 감지 순서를 가져올 때 인코딩의 정렬된 배열이 반환됩니다.


변경 로그

Version Description
8.0.0 encoding은 이제 nullable입니다.

Examples

예제 #1 mb_detect_order() 예제

                  
<?php
/* 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());
?>
                  
                

예제 #2 쓸모없는 감지 명령을 보여주는 예

; Always detect as ISO-8859-1
detect_order = ISO-8859-1, UTF-8

; Always detect as UTF-8, since ASCII/UTF-7 values are
; valid for UTF-8
detect_order = UTF-8, ASCII, UTF-7
                

기타