You see, maxle...">

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

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

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

 echo strlen($title); 

Any idea?

By the way, I introduced Japanese text . What's wrong?
+4
source share
3 answers

Japanese text most likely uses multibyte character encoding. Therefore you should use mb_strlen () .

Best regards, Fabian

+13
source

What's wrong?

PHP string processing based on the assumption that 1 character = 1 byte, and leaves it to the programmer to damage the encoding all over the world and do not forget to use the later mb_ * functions whenever it comes to strings that can use multibyte encodings.

+5
source

maxlength is just a browser lock, but it is bypassed in any way, including Unicode encoding. To do this, it is better to provide server-side management.

-2
source

All Articles