php 将ascii中文乱码,php如何将中文转ascii_后端开发

php中文转ascii的要领:起首建立一个PHP示例文件;然后定义一个“strtoascii”要领;接着运用“mb_convert_encoding”函数转换编码;末了实行该文件并输出转换效果即可。

2f6165c2cca96de6d08cdd6301695f7a.png

引荐:《PHP教程》

将字符串(中文一样有用)转为ascii(注重:我默许当前我们的php文件环境是UTF-8,如果是GBK的话mb_convert_encoding操纵就不须要)

public function strtoascii($str){

$str=mb_convert_encoding($str,'GB2312');

$change_after='';

for($i=0;$i

$temp_str=dechex(ord($str[$i]));

$change_after.=$temp_str[1].$temp_str[0];

}

return strtoupper($change_after);

以上就是php如何将中文转ascii的细致内容,更多请关注ki4网别的相干文章!

收藏 | 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值