Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 268
Steven Avatar asked Dec 06 '22 04:12

Steven


1 Answers

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

Best wishes, Fabian

like image 106
halfdan Avatar answered Dec 07 '22 23:12

halfdan