Why my php substr() shows obscure characters when cutting a text?

后端 未结 4 848
夕颜
夕颜 2020-12-31 16:48

I\'m using the substr() function to limit the characters in strings. but sometimes, the output text contains some obscure characters and Question marks etc...

4条回答
  •  梦毁少年i
    2020-12-31 17:24

    Because you are cutting your characters into half.

    Use mb_substr for multibyte character encodings like UTF-8. substr just counts bytes while mb_substr counts characters.

提交回复
热议问题