- You need the
mb_
string functions in place of the regular string functions, e.g.mb_substr
instead ofsubstr
. If you don't use the regular string functions, there's no use for themb_
functions either. - If you're just passing text through and PHP isn't doing anything with that text, there's no need for the
mb_
functions. - To make the
mb_
functions work correctly, you'll have to tell them what encoding your text is in. They support many different encodings, without telling them which you're using their results will be incorrect. You can pass that encoding to eachmb_
function call, e.g.mb_strlen($str, 'UTF-8')
, or you can set it once for allmb_
functions usingmb_internal_encoding('UTF-8')
.
See What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text for a comprehensive introduction.