Home  >  Article  >  Detailed explanation of introduction and usage of strlen function

Detailed explanation of introduction and usage of strlen function

不言
不言Original
2018-05-09 15:47:4213564browse

The content of this article is about the comparison between strlen() and mb_strlen() in PHP. It has certain reference value. Now I share it with you. Friends in need can refer to it. This article is original by the blogger. If you reprint it Please indicate the source. First, let’s take a look at what the official documentation says; strlen()-is used to obtain the string length int strlen (string $string) and returns the length of the given string string. mb_strlen — Get the length of a string mixed mb_strlen ( string $str[, string $encoding = mb_internal_encoding() ] ) Get the length of a string. str: The string whose length is to be checked. encoding: The encoding parameter is the character encoding

1. Comparison of strlen() and mb_strlen() in PHP

Detailed explanation of introduction and usage of strlen function

Introduction: This article introduces the comparison between strlen() and mb_strlen() in PHP. It has certain reference value. Now I share it with everyone. Friends in need can For reference

2. php performance optimization: isset() is faster than strlen()

Introduction: Many Programmers like to use functions such as strlen() mb_strlen() when determining the length of a string. Although they have been professionally testing string lengths, they do not know that functions such as strlen() mb_strlen() are not optimal. In fact, when PHP determines the length of a string, using isset() is faster than strlen() and has higher execution efficiency. To determine the length of a string in PHP, using isset() is faster than strlen() and has higher execution efficiency.

3. php function strlen() that returns the length of a string

Introduction: This article introduces in detail PHP's function strlen(), which returns the length of a string, has certain reference value. Let's take a look at it together!

4. Do you know the difference between strlen and mb_strlen in php?

Introduction: Common functions for calculating string length in PHP are: strlen and mb_strlen. When the characters are all English characters, the two are the same. Here we mainly compare the two calculation results when Chinese and English are mixed.

5. A brief introduction to the difference between strlen and mb_strlen in php

Introduction: Common calculation characters in php The functions of string length are: strlen and mb_strlen. When the characters are all English characters, the two are the same. Here we mainly compare the two calculation results when Chinese and English are mixed.

6. PHP gets the string length function strlen() function

Detailed explanation of introduction and usage of strlen function

Introduction: In some website registration or other activities, we need users to submit some information, and there will be certain requirements for this information. For example, there are some restrictions on the length of user registration information, which cannot be less than or greater than this. Here we need to use PHP's own functions to perform the acquisition operation.

7. Briefly talk about the strlen function in PHP

Detailed explanation of introduction and usage of strlen function

##Introduction: In PHP, the function strlen() returns the length of the string. The strlen() function returns the length of bytes occupied by the string. An English letter, number, and various symbols all occupy one byte. They The lengths are all 1

8. PHP string length calculation - introduction to the use of strlen() function

Detailed explanation of introduction and usage of strlen function

Introduction: In PHP, the function strlen() returns the length of the string. The strlen() function returns the length of bytes occupied by the string, an English letter, number, Each symbol occupies one byte, and their length is 1

9. php strlen mb_strlen计算中英文混排字符串长度

Detailed explanation of introduction and usage of strlen function

简介:在php中常见的计算字符串长度的函数有:strlen和mb_strlen,下面是对这两个函数的比较说明(编码方式UTF8)

10. 简单谈谈PHP中strlen 函数

Detailed explanation of introduction and usage of strlen function

简介:在PHP中,函数strlen()返回字符串的长度,strlen()函数返回字符串所占的字节长度,一个英文字母、数字、各种符号均占一个字节,它们的长度均为1

11. php中strlen和mb_strlen用法实例分析

Detailed explanation of introduction and usage of strlen function

简介:这篇文章主要介绍了php中strlen和mb_strlen用法,结合实例形式分析了strlen和mb_strlen针对中英文结合字符编码计算字符串长度的操作技巧,需要的朋友可以参考下

12. PHP字符串长度计算 - strlen()函数使用介绍

Detailed explanation of introduction and usage of strlen function

简介:在PHP中,函数strlen()返回字符串的长度,strlen()函数返回字符串所占的字节长度,一个英文字母、数字、各种符号均占一个字节,它们的长度均为1

13. 简单谈谈PHP中strlen 函数

Detailed explanation of introduction and usage of strlen function

简介:在PHP中,函数strlen()返回字符串的长度,strlen()函数返回字符串所占的字节长度,一个英文字母、数字、各种符号均占一个字节,它们的长度均为1

14. php strlen mb_strlen计算中英文混排字符串长度

Detailed explanation of introduction and usage of strlen function

简介:在php中常见的计算字符串长度的函数有:strlen和mb_strlen,下面是对这两个函数的比较说明(编码方式UTF8)

15. 细说PHP中strlen和mb_strlen的区别

Detailed explanation of introduction and usage of strlen function

简介:在PHP中,strlen与mb_strlen是求字符串长度的函数,但是对于一些初学者来说,如果不看手册,也许不太清楚其中的区别。 下面通过例子,讲解这两者之间的区别。  先看例子:      <?php        //测试时文件的编码方式要是UTF8        $str='中文a字1符';        echo strlen($str).'<br>'; ...

16. php判断字符串长度 strlen()与mb_strlen()函数

Detailed explanation of introduction and usage of strlen function

简介:strlen()  PHP strlen() 函数  定义和用法  strlen() 函数返回字符串的长度。  语法  strlen(string)  参数:string 描述:必需。规定要检查的字符串。   代码如下  � ...

17. php Get the number of words mixed in English and Chinese iconv_strlen

Introduction:: This article mainly introduces php to get the mixed number of English and Chinese The word count iconv_strlen, students who are interested in PHP tutorials can refer to it.

18. A brief talk about the strlen function in PHP

Introduction::This article mainly introduces a brief talk about Talking about the strlen function in PHP, students who are interested in PHP tutorials can refer to it.

19. strlen php strlen mb_strlen calculates the length of mixed Chinese and English strings

Introduction: strlen: strlen php strlen mb_strlen calculates the length of mixed Chinese and English strings: compare strlen and mb_strlen. When the characters are all English characters, the two are the same. Here we mainly compare the two calculation results when Chinese and English are mixed. (The encoding method during testing is UTF8) Copy the code as follows:'; echo mb_strlen($str ,'UTF8'); //Output result//14 //6 ?&g

20. php strlen mb_strlen calculates the length of mixed Chinese and English strings_PHP tutorial

Introduction: php strlen mb_strlen calculates the length of mixed Chinese and English strings. Compare strlen and mb_strlen. When the characters are all English characters, they are the same. Here we mainly compare the two calculation results when Chinese and English are mixed. (The encoding method during testing is

21. Detailed explanation of mb_strlen and strlen functions in php_PHP tutorial

Introduction: Detailed explanation of mb_strlen and strlen functions in php //The encoding method of the file during testing must be utf8 $str=Chinese a character; echo strlen($str). ;//14 echo mb_strlen($str,utf8). ;// 6 echo mb_strlen($str,gbk). ;//8 echo mb_strlen($str,gb2312).

22. Judge character length function strlen example tutorial_PHP tutorial

Introduction: Example tutorial of determining character length function strlen. Definition and usage The length string returned by the strlen () function. Its function is to calculate the character length, Chinese. One word is 2 Syntax strlen(string) Parameter Description string R

##23. Details the difference between strlen and mb_strlen in PHP_PHP tutorial

Introduction: Describe the difference between strlen and mb_strlen in PHP. In PHP, strlen and mb_strlen are functions to find the length of a string, but for some beginners, it may not be easy to understand without reading the manual. Understand the difference. Let’s take an example,

##24.

The difference between strlen, mb_strlen, substr(), mb_substr() and mb_strcut in php_PHP tutorial

Introduction: The differences between strlen, mb_strlen, substr(), mb_substr() and mb_strcut in PHP are introduced in detail. Students who need to learn can refer to the difference and usage of mb_* string splitting function:

##25.

php mb_strlen() Chinese and English mixed characters. Interception code_PHP tutorial

Introduction: php mb_strlen() Chinese and English mixed character interception code Note: If a fatal error occurs when using mb_strlen, call to undefined function mb_strlen. For this kind of problem, you can use the php tutorial info() to see if mbstring is loaded. If not, try to

[Related Q&A recommendations]:

c - String type length problem

php - echo strlen('Hello'); What is displayed is 6, why is it 6 (it should be 4, logically)?

What does this explanation about namespaces in the PHP manual mean?

Why does strlen count Chinese characters as 3 bytes under UTF-8? Chinese characters are not 2 bytes?

Why can’t strlen() be used for const char[] in C?

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