mb_convert_variables
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
mb_convert_variables — 转换一个或多个变量的字符编码
说明
mb_convert_variables(
string
mixed
mixed
mixed
): string
string
$to_encoding
,mixed
$from_encoding
,mixed
&$vars
,mixed
&$...
= ?): string
将变量 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
。
范例
示例 #1 mb_convert_variables() 例子
<?php
/* 转换变量 $post1、$post2 编码为内部(internal)编码 */
$interenc = mb_internal_encoding();
$inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $post2);
?>

User Contributed Notes
There are no user contributed notes for this page.
备份地址:http://www.lvesu.com/blog/php/function.mb-convert-variables.php