Php string length function _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Php string length function. 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, below is my php string length function. in php, there are two function tests of string length: one is strlen, the other is supported by the first one before mb_strlen, and 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 ):


Http://www.bkjia.com/PHPjc/445409.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445409.htmlTechArticlephp string length function, in php test string length function has two, one is strlen, the other is mb_strlen before the default is supported, the latter needs to enable a plug-in, below I...

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.