(PHP 4, PHP 5, PHP 7, PHP 8)
strlen — 获取字符串长度
$string): int
   返回给定的字符串 string 的长度。
  
string需要计算长度的字符串。
   成功则返回字符串 string 的长度;如果 string 为空,则返回 0。
  
| 版本 | 说明 | 
|---|---|
| 5.3.0 | Prior versions treated arrays as the string Array, thus returning
       a string length of5and emitting anE_NOTICElevel error. | 
示例 #1 strlen() 范例
<?php
$str = 'abcdef';
echo strlen($str); // 6
$str = ' ab cd ';
echo strlen($str); // 7
?>
注意:
strlen() returns the number of bytes rather than the number of characters in a string.
注意:
strlen() returns
nullwhen executed on arrays, and anE_WARNINGlevel error is emitted.