源代码:
<HTML> <HEAD></HEAD> <FONT FACE="'Courier New',Verdana, Arial, Helvetica" SIZE=2> <!DOCTYPE html> <html> <body> <FONT COLOR=#ff0000><?php $str = "This is nice"; echo strlen($str)." "; // Using strlen() to return the string length echo substr_count($str,"is")." "; // The number of times "is" occurs in the string echo substr_count($str,"is",2)." "; // The string is now reduced to "is is PHP" echo substr_count($str,"is",3)." "; // The string is now reduced to "s is PHP" echo substr_count($str,"is",3,3)." "; // The string is now reduced to "s i" ?></FONT> </body> </html> </HTML>
运行结果:
<HTML> <HEAD></HEAD> <FONT FACE="'Courier New',Verdana, Arial, Helvetica" SIZE=2> <!DOCTYPE html> <html> <body> <FONT COLOR=#ff0000>12 2 2 1 0 </FONT> </body> </html> </HTML>