strlen

(PHP 4, PHP 5, PHP 7, PHP 8)

strlen获取字符串长度

说明

strlen(string $string): int

返回给定的字符串 string 的长度。

参数

string

需要计算长度的字符串

返回值

返回 string 的字节数。

范例

示例 #1 strlen() 范例

<?php
$str
= 'abcdef';
echo
strlen($str); // 6

$str = ' ab cd ';
echo
strlen($str); // 7
?>

注释

注意:

strlen() 返回的是字符串的字节数,而不是其中字符的数量。

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top