PHP mb_substr()无法正常工作? [英] PHP mb_substr() not working correctly?
本文介绍了PHP mb_substr()无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码
print mb_substr('éxxx', 0, 1);
打印一个空白:(
应该打印第一个字符é
.但是,这似乎可行:
It is supposed to print the first character, é
. This seems to work however:
print mb_substr('éxxx', 0, 2);
但这是不对的,因为(0,2)表示2个字符...
But it's not right, because (0, 2) means 2 characters...
推荐答案
尝试将编码参数传递给mb_substr,例如:
Try passing the encoding parameter to mb_substr, as such:
print mb_substr('éxxx', 0, 1, 'utf-8');
永远不会自动检测到编码.
The encoding is never detected automatically.
这篇关于PHP mb_substr()无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文