Home  >  Article  >  Backend Development  >  How to use php strlen function

How to use php strlen function

藏色散人
藏色散人Original
2019-02-11 11:09:573434browse

The strlen function is a built-in function in PHP. The syntax is strlen(string), which is used to obtain the length of a string. This function calculates the length of a string, including all spaces and special characters; it takes the given string as an argument and returns its length.

How to use php strlen function

php How to use strlen() function?

php strlen() function returns the length of the string

Syntax:

strlen(string)

Parameters:

string: required. Specifies the string to check.

Return value: Returns the length of the string.

php strlen() function example 1

<?php
echo strlen("I love php!");
?>

Output:

11

php strlen() function example 2

<?php
echo strlen("i study php at php.cn");
?>

Output:

21

This article is an introduction to the PHP strlen function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use php strlen function. For more information, please follow other related articles on 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