Last Updated: February 25, 2016
·
864
· jverdeyen

mb_strlen for multibyte strings

If you are using strlen() on a multibyte string then you might get a wrong result, if you want to know the number of characters used.

Instead use mb_strlen(), it will count the multibyte chars as 1 char.

mb_strlen is slower than strlen(), but safer if you're expecting exotic characters.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#php
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside