PHP string length function _php Tutorial

Source: Internet
Author: User
PHP string length function, in PHP test string length function has two, one is strlen, the other is Mb_strlen before a default is supported, the latter need to open a plug-in, let us introduce the difference between the two functions and application methods.

PHP Tutorial String length function , in PHP test string length function has two, one is strlen, the other is Mb_strlen before a default is supported, the latter need to open a plug-in, let us introduce the difference between the two functions and application methods.

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

Grammar
strlen (String) parameter description
string is required. Specifies the string to check.

Echo strlen ("www.bkjia.com!");//13
echo strlen ("Chinese!"); /6 Strlen The value is twice times the number of Chinese characters
?>

Attempt to copy Php_mbstring.dll to the%windows% directory

$str = ' understand PHP know strlen and Mb_strlen is the function of the length of the string ';
echo strlen ($STR) '.
'. Mb_strlen ($str, ' utf-8 ');
?>

Running the above code, the return value is as follows:
66
34

Understand PHP know Strlen and Mb_strlen is the function of the length of the string, but for some beginners, if you do not read the manual, it may not be clear that the difference.
First look at this piece of code (the prerequisite is: Character encoding is utf-8):


http://www.bkjia.com/PHPjc/445409.html www.bkjia.com true http://www.bkjia.com/PHPjc/445409.html techarticle php string length function, in PHP test string length function has two, one is strlen, the other is Mb_strlen before a default is supported, after a need to open a plugin, below I ...

  • Related Article

    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.