PHP strlen()Functions

PHP String 参考手册PHP String Reference Manual

Examples

The function returns the length of the string "Hello":

<?php
echo strlen("Hello");
?>

Run Example »

Definition and Usage

The strlen() function returns the length of a string. For processing Chinese strings, use themb_strlen() function。。


Syntax

strlen(string)

Parameters Description
string Required. Specifies the string to be checked.

Technical Details

Return Value: Returns the length of the string on success, or 0 if the string is empty.
PHP Version: 4+
Changelog: Before PHP 5.3.0, this function treated an array as a stringArray, thus returning a string of length 5 and producing an E_NOTICE level error.


More Examples

Example 1

Returns the length of the string "Hello World":

<?php
echo strlen("Hello world!");
?>

Run Example »


PHP String 参考手册PHP String Reference Manual Other Extensions