(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
/* 轉換變量 $post1、$post2 編碼為內部(internal)編碼 */
$interenc = mb_internal_encoding();
$inputenc = mb_convert_variables($interenc, "ASCII,UTF-8,SJIS-win", $post1, $post2);
?>