超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<stristrstrnatcasecmp>
Last updated: Fri, 22 Jun 2007

strlen

(PHP 3, PHP 4 , PHP 5)

strlen -- Get string length

Description

int strlen ( string string)

Returns the length of the given string.

例子 1. A strlen() example

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

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

See also count(), and mb_strlen().




add a note add a note User Contributed Notes
strlen
rasmus at php dot net
04-Nov-2000 03:37
This bit of code works just fine in PHP:

$tmp=0; $s="blah";
while($c=$s[$tmp++]) { echo $c; }

Depending on your warning level you may get a warning when $tmp = 4 because you have gone beyond the end of the string.  If you don't care about this warning either change your warning level or simply swallow it using:

 $tmp=0; $s="blah";
 while(@$c=$s[$tmp++]) { echo $c; }

The @ in front of the assignment will swallow any warnings from that assignment.

<stristrstrnatcasecmp>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22