2020-12-20

PHP 글자수 계산하기 : EUC-KR, UTF-8 환경에서

 <?
$sms_txt = "한글입니다한글입니다"; 

$t_length = mb_strwidth($sms_txt,'EUC-KR');
 
$t2_length = mb_strwidth($sms_txt); 

echo "$sms_txt // $t_length byte / $t2_length";
// 둘다 결과값이 같다.
?>



<?

$sms_txt = "한글입니다한글입니다."; 

$t_length = mb_strwidth($sms_txt,'UTF-8'); 
$t2_length = mb_strwidth($sms_txt); 

echo "$sms_txt // $t_length byte / $t2_length";

// 둘다 결과값이 같다.

?>





댓글 없음:

댓글 쓰기