Php String Length Function

Source: Internet
Author: User

Php String Length function. In php, two functions are used to test the string length. One is strlen, and the other is supported by the previous one before mb_strlen by default. The other one needs to enable a plug-in, next we will introduce the differences between the two functions and the application methods.

Php tutorial String Length FunctionIn php, two functions are used to test the string length. One is strlen, and the other is supported by the previous one by default. The other one needs to enable a plug-in, next we will introduce the differences between the two functions and the application methods.

Php strlen () function
Definition and usage
The strlen () function returns the length of the string.

Syntax
Strlen (string) parameter description
String is required. Specifies the string to be checked.

Echo strlen ("www.bkjia.com! "); // 13
Echo strlen ("Chinese! "); // The value obtained by strlen 6 is twice the number of Chinese Characters
?>

Try to copy php_mbstring.dll to the % windows % directory

$ Str = 'all php users know that strlen and mb_strlen are functions for string lengths ';
Echo strlen ($ str )'.
'. Mb_strlen ($ str, 'utf-8 ');
?>

Run the preceding code and return the following values:
66
34

All php users know that strlen and mb_strlen are functions used to evaluate the string length. However, for some beginners, if they do not read the manual, they may not know the difference.
Let's take a look at this piece of code first (the prerequisite is: the character encoding is UTF-8 ):


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.