文字

mb_convert_variables

(PHP 4 >= 4.0.6, PHP 5)

mb_convert_variables转换一个或多个变量的字符编码

说明

string mb_convert_variables ( string $to_encoding , mixed $from_encoding , mixed &$vars [, mixed &$... ] )

将变量 vars 的编码从 from_encoding 转换成编码 to_encoding

mb_convert_variables() 会拼接变量数组或对象中的字符串来检测编码,因为短字符串的检测往往会失败。因此,不能在一个数组或对象中混合使用编码。

参数

to_encoding

string 转换成这个编码。

from_encoding

from_encoding 可以指定为一个 array 或者逗号分隔的 string ,它将尝试根据 from-coding 来检测编码。 当省略了 from_encoding,将使用 detect_order

vars

vars 是要转换的变量的引用。 参数可以接受 String、Array 和 Object 的类型。 mb_convert_variables() 假设所有的参数都具有同样的编码。

...

额外的 vars

返回值

成功时返回转换前的字符编码,失败时返回 FALSE

范例

Example #1 mb_convert_variables() 例子

<?php

$interenc  mb_internal_encoding ();
$inputenc  mb_convert_variables ( $interenc "ASCII,UTF-8,SJIS-win" $post1 $post2 );
?>

用户评论:

[#1] ryosuke_i_628 at yahoo dot co dot jp [2014-03-27 08:16:52]

This function has a bug on recursion detection.
https://bugs.php.net/bug.php?id=66964

上一篇: 下一篇: