µ±Ç°Î»Ö㺠´úÂëÃÔ >> PHP >> ¡¾Í¨Òë¡¿ÓÃPHPÈ¡µÃ×Ö·û´®µÄ³¤¶È£¨strlen,mb_strlen£©
  Ïêϸ½â¾ö·½°¸

¡¾Í¨Òë¡¿ÓÃPHPÈ¡µÃ×Ö·û´®µÄ³¤¶È£¨strlen,mb_strlen£©

Èȶȣº323   ·¢²¼Ê±¼ä£º2016-04-28 22:57:05.0
¡¾·­Òë¡¿ÓÃPHPÈ¡µÃ×Ö·û´®µÄ³¤¶È£¨strlen,mb_strlen£©
È¡µÃ×Ö·û´®µÄ³¤¶È¡£
strlenint strlen(string str)

È¡µÃÖ¸¶¨Îª²ÎÊýµÄ×Ö·û´®µÄ³¤¶È¡£ÒòΪȡµÃµÄÊÇ×Ö½ÚÊý£¬ËùÒÔ°ë½ÇÎÄ×ÖΪ1×Ö½Ú£¬È«½ÇÎÄ×ÖΪ2×Ö½Ú¡£

²ÎÊý£º
  str ¶ÔÏóµÄ×Ö·û´®
·µ»ØÖµ£º
  ×Ö·û´®µÄ×Ö½ÚÊý

¹ØÓÚ°ë½ÇÎÄ×ÖºÍÈ«½ÇÎÄ×ֵij¤¶È£¬¾ÙÀýÈçÏ£º
strlen('abc') --> 3strlen('¤¢¤¤¤¦') --> 6strlen('abc¤¢¤¤¤¦') --> 9

²»ÊÇÈ¡µÃ×Ö½ÚÊý£¬¶øÊÇÈ¡µÃÎÄ×ÖÊýµÄÇéÐΣ¬ÔòʹÓÃ[mb_strlen]º¯Êý¡£²»¹ý°ë½ÇÎÄ×Ö»¹ÊÇÈ«½ÇÎÄ×Ö£¬
¶¼°´1ÎÄ×Ö½øÐд¦Àí¡£
mb_strlenint mb_strlen(string str [, string encoding])

²ÎÊý£º
  string ¶ÔÏóµÄ×Ö·û´®
  encoding ¶ÔÏóµÄ×Ö·û´®µÄÎÄ×Ö±àÂë

·µ»ØÖµ£º
  ×Ö·û´®µÄÎÄ×Ö£¨¸ö£©Êý

ÏÂÃæʵ¼Ê²âÊÔ¿´¿´¡£
<html><head><title>PHP TEST</title></head><body><?php$str1 = 'abcde';$str_len1 = strlen($str1);$str_mblen1 = mb_strlen($str1);$str2 = '10•r20·Ö';$str_len2 = strlen($str2);$str_mblen2 = mb_strlen($str2);print($str1.' ¤ÎÎÄ×ÖÁФÎéL¤µ¤Ï'.$str_len1.'¤Ç¤¹<br>');print($str1.' ¤ÎÎÄ×ÖÊý¤Ï'.$str_mblen1.'¤Ç¤¹<br><br>');print($str2.' ¤ÎÎÄ×ÖÁФÎéL¤µ¤Ï'.$str_len2.'¤Ç¤¹<br>');print($str2.' ¤ÎÎÄ×ÖÊý¤Ï'.$str_mblen2.'¤Ç¤¹<br><br>');?></body></html>

°ÑÉÏÊöÎļþ·¢²¼µ½WEB·þÎñÆ÷£¬¾­ÓÉä¯ÀÀÆ÷·ÃÎÊ£¬ÏÔʾ½á¹ûÈçÏ¡£


  Ïà¹Ø½â¾ö·½°¸