函数名称:recode_string()
函数描述:该函数用于将字符串转换为指定字符集的编码。
适用版本:PHP 4 >= 4.0.5, PHP 5, PHP 7
语法:string recode_string ( string $request , string $string )
参数:
返回值:返回转换后的字符串,如果转换失败则返回 FALSE。
示例:
// 将字符串从 ISO-8859-1 转换为 UTF-8
$input = "Hello, World!";
$output = recode_string("iso-8859-1..utf-8", $input);
echo $output; // 输出:Hello, World!
// 将字符串从 GB2312 转换为 UTF-8
$input = "你好,世界!";
$output = recode_string("gb2312..utf-8", $input);
echo $output; // 输出:你好,世界!
注意事项: