strlen

(PHP 4, PHP 5, PHP 7)

strlen锟斤拷取锟街凤拷锟斤拷锟斤拷锟斤拷

说锟斤拷

strlen ( string $string ) : int

锟斤拷锟截革拷锟斤拷锟斤拷锟街凤拷锟斤拷 string 锟侥筹拷锟饺★拷

锟斤拷锟斤拷

string

锟斤拷要锟斤拷锟姐长锟饺碉拷锟街凤拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟缴癸拷锟津返伙拷锟街凤拷锟斤拷 string 锟侥筹拷锟饺o拷锟斤拷锟� string 为锟秸o拷锟津返伙拷 0锟斤拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
5.3.0 Prior versions treated arrays as the string Array, thus returning a string length of 5 and emitting an E_NOTICE level error.

锟斤拷锟斤拷

Example #1 strlen() 锟斤拷锟斤拷

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

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

注锟斤拷

Note:

strlen() returns the number of bytes rather than the number of characters in a string.

Note:

strlen() returns NULL when executed on arrays, and an E_WARNING level error is emitted.

锟轿硷拷

  • count() - 锟斤拷锟斤拷锟斤拷锟斤拷锟叫的碉拷元锟斤拷目锟斤拷锟斤拷锟斤拷锟斤拷械锟斤拷锟斤拷愿锟斤拷锟�
  • mb_strlen() - 锟斤拷取锟街凤拷锟斤拷锟侥筹拷锟斤拷