I understand why mb_ functions are useful. But I'm not sure if there's any reason to keep using old plain string functions. As programming teacher, I wonder if I should just skip those in favor of their multibyte versions.
Related Questions:
I understand why mb_ functions are useful. But I'm not sure if there's any reason to keep using old plain string functions. As programming teacher, I wonder if I should just skip those in favor of their multibyte versions.
Related Questions:
Not all string operations are reimplemented as mb_ function, for instance there's no mb_ equivalent to str_replace. The reason is that it's not really necessary, since str_replace works just fine on strings of any encoding if you take care that the arguments are all in a consistent encoding.
So, you cannot simply ignore all "old plain string functions" altogether. You need to use the mb_ functions if you're doing something which requires encoding- and character-awareness. For other purposes, you don't necessarily.
The "old plain string functions" are also helpful if you're explicitly trying to work with bytes rather than characters. For example, you can use substr to test for the presence of a BOM:
if (substr($str, 0, 3) == "\xEF\xBB\xBF")