如何在PHP中将变量(文本/字符串)转换为utf8mb4 [英] How to convert variable (text/string) to utf8mb4 in php
本文介绍了如何在PHP中将变量(文本/字符串)转换为utf8mb4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找utf8mb4的编码功能,
Hi I'm looking for a encode function for utf8mb4,
$var = = "نور";
echo utf8mb4_encode($string);
output = نور // its $var output in UTFMB4
输出应为نور",即utfmb4中$ var的转换
The output should be "نور" this, its a conversion of $var in utfmb4
推荐答案
mb_convert_encoding函数的返回值可以为您提供所需的结果.
The return value of the mb_convert_encoding function could give you the desired result.
$string = "نور";
$result = mb_convert_encoding($string, 'UTF-8', 'Windows-1252');
//$result = mb_convert_encoding($string, 'UTF-8', 'Windows-1254');
echo $result;
这篇关于如何在PHP中将变量(文本/字符串)转换为utf8mb4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文