Home  >  Article  >  Backend Development  >  Example analysis of strlen and mb_strlen usage in php

Example analysis of strlen and mb_strlen usage in php

高洛峰
高洛峰Original
2016-12-26 13:14:211310browse

This article analyzes the usage of strlen and mb_strlen in php with examples. Share it with everyone for your reference, the details are as follows:

First look at the following code (file encoding utf8):

Running result:

int 19
 
int 13
 
int 9
 
int 19

When the second parameter is the same as the original encoding of the string, the real number of words in the sense of human understanding will be calculated. (Chinese characters only count once)

I hope this article will be helpful to everyone in PHP programming.

For more related articles on the usage examples of strlen and mb_strlen in PHP, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn