This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

864 points
Picture
Submitted by
Matti Järvinen
over 2 years ago

strlen vs. mb_strlen substr vs. mb_substr

I think it is "dangerous" to teach people to use strlen and substr. In practice mb_strlen and mb_substr are used instead since strlen doesn't work right with UTF-8 strings like "ä" -> strlen("ä") == 2 mb_strlen("ä",'UTF_8') == 1

For PHP code that works globally using strlen and substr is not an option.


0 votes

permalink

Hey Matti,

Unfortunately, I don't think the creator of this course plans on updating it, but that's definitely very interesting. Since Codecademy focuses on being global, I'm surprised that they didn't notice that the course doesn't work with special characters.

2818 points
5674c6dae39efec455000434_879409444
Submitted by
Zeke Y
over 2 years ago