Multibyte String 函数
在线手册:中文 英文
PHP手册

mb_http_input

(PHP 4 >= 4.0.6, PHP 5)

mb_http_inputDetect HTTP input character encoding

说明

mixed mb_http_input ([ string $type = "" ] )

Detects the HTTP input character encoding.

参数

type

Input string specifies the input type. "G" for GET, "P" for POST, "C" for COOKIE, "S" for string, "L" for list, and "I" for the whole list (will return array). If type is omitted, it returns the last input type processed.

返回值

The character encoding name, as per the type. If mb_http_input() does not process specified HTTP input, it returns FALSE.

参见


Multibyte String 函数
在线手册:中文 英文
PHP手册
PHP手册 - N: Detect HTTP input character encoding

用户评论:

anders jenbo pc dk (23-Oct-2007 04:00)

As this does not seam to work (always returns "pass"). you can use

$encoding = mb_detect_encoding(urldecode($REQUEST_URI), 'UTF-8, UTF-7, ASCII, EUC-JP,SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP, ISO-8859-1');

to detect the encoding of the url instead, similare steps could be taken to deteck cookies and post data although it would have to be done for each value.