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
기타
- mb_internal_encoding() - 내부 문자 인코딩 설정/가져오기
- mb_http_input() - HTTP 입력 문자 인코딩 감지
- mb_http_output() - HTTP 출력 문자 인코딩 설정/가져오기
- mb_send_mail() - 인코딩된 메일 보내기