Search code examples
phphtmllocalizationmaxlength

If HTML maxlength is 110, why can I input 114 characters?


<input type="text" id="title" name="title" size="50" maxlength="110" />

You see, the maxlength is 110, but I was shocked when I found that I input 114 characters when I used

echo strlen($title);

Any idea?

By the way, what I input was Japanese text. What's wrong?


Solution

  • Japanese text is most probably using a multibyte character encoding. Therefore you should make use of mb_strlen().

    Best wishes, Fabian