However, if the Utf-8 encoding, a Chinese character is 3 characters in length, such as the string $str= "Hello Ah!!";
If you use the Strlen function to judge that the length is 11, just over the length of the varchar, but in fact it is not so, if directly into the phpMyAdmin inside the INSERT statement, this string can be inserted!
For a database, its length is 5, then how do we use PHP to get this length? Use the Iconv_strlen () function!
Echo Iconv_strlen ($str, ' utf-8′);
Note that the second argument is the current character set, so that depending on the character set, the result you get is calculated from one character per length!
The above statement, will output 5, how, you will judge it?
http://www.bkjia.com/PHPjc/323649.html www.bkjia.com true http://www.bkjia.com/PHPjc/323649.html techarticle However, if the Utf-8 encoding, a Chinese character is 3 characters in length, such as the string $str= "Hello Ah!!"; If you use the Strlen function to judge, the length is 11, just over the Varch ...