strlen

文字列の長さを得る

説明

int strlen(string $string)

与えられた string の長さを返します。

パラメータ

string

長さを調べる文字列。

戻り値

string の長さをバイト単位で返します。

例1 strlen の例

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

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

注意

注意:

strlen が返すのはバイト数であり、 文字数ではありません。

参考

  • count
  • grapheme_strlen
  • iconv_strlen
  • mb_strlen