php ½ØÈ¡utf 8×Ö·û´®
ÕÒÁ˺ܶàÕâÑùµÄº¯Êý£¬»¹ÊǾõµÄÕâ¸ö×îºÃÁË
$a = 'aadfdsf¶á¶¥ÌæÒ»¿Ý»ù22245¶¥ÌæsdffhѹÏÂ';
/**
* ½ØÈ¡utf-8×Ö·û
* @param string $string
* @param int$length
*
* return string
*/
function cutstr($string, $length) {
preg_match_all("/./u", $string, $info);
$i = 0;
$str = '';
foreach($info[0] as $item){
if(strlen($item) == 3){
$i+=2;
}else{
$i++;
}
$str .= $item;
if($i>=$length)break;
}
return $str;
}
echo cutstr($a, 10); //-> aadfdsf¶á¶¥
Ïà¹ØÎĵµ£º
1.ÏÂÔØ°²×°mcrypt
ÏÈÈ¥http://www.sourceforge.netÏÂÔØLibmcrypt,mhash,mcrypt°²×°°ü
2 .ÏȰ²×°Libmcrypt
#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install
˵Ã÷£ºlibmcriptĬÈϰ²×°ÔÚ/usr/local
3.°²×°mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./ ......
·½·¨1£ºerror_reporting (E_ALL ^ E_WARNING);
session_start();
·½·¨2£ºerror_reporting (E_ALL & ~E_NOTICE);
if (!isset($_SESSION)) {
session_start();
};
·½·¨3£º¸Äphp.ini ÖÐerror_reporting ......
ÎÒ×îÔç½Ó´¥µÄ±à³Ì¹¤¾ßÊÇDreamweaver£¬ÆäʵӦ¸ÃÊÇ×¼±à³Ì¹¤¾ß°É£¬ÎÒÄÇʱºòÓõĺÃÏñÊÇ
4£¬Èç¹ûÎÒûÓмǴíµÄ»°£¬È»ºóºóÀ´»¹ÓÐÒ»¸ö°æ±¾½ÐUtralµÄ£¬´Ó×î³õÆÚµÄ°æ±¾Ò»Ö±µ½ÏÖÔÚµÄCS4£¬µ±ÄêµÄMicromedia¹«Ë¾ÒѾ±»Adobe¹«Ë¾
ÊÕ¹ºÁË£¬ÎÒ»¹ÊÇÔÚÓá£ÔÚHTMLµÄ±à¼·½Ã棬DWÓÐ×ÅÎ޿ɱÈÄâµÄÓÅÊÆ£¬ÎÒÏÖÔÚд.Net»¹ÊÇϰ¹ßÔÚDWÀï½øÐÐÒ³Ãæ²¼¾ ......
¡¡PHPÖÐÎÄÂÒÂëÊÇPHP¿ª·¢Öеij£¼ûÎÊÌâÖ®Ò»¡£PHPÖÐÎÄÂÒÂëÓÐʱ·¢ÉúÔÚÍøÒ³±¾Éí£¬ÓÐЩ²úÉúÔÚÓÚMySQL½»»¥µÄ¹ý³ÌÖУ¬ÓÐʱÓë²Ù×÷ϵͳÓйء£ÏÂ
Ãæ½øÐÐÒ»·¬×ܽᡣ
¡¡¡¡Ò».Ê×ÏÈÊÇPHPÍøÒ³µÄ±àÂë
¡¡¡¡1. phpÎļþ±¾ÉíµÄ±àÂëÓëÍøÒ³µÄ±àÂëӦƥÅä
¡¡¡¡a. Èç¹ûÓûʹÓÃgb2312±àÂ룬ÄÇôphpÒªÊä³öÍ·£ºheader(“Content-Type: text/html; ......
PHP³ÌÐòÉè¼ÆÖÐÖÐÎıàÂëÎÊÌâÔø¾À§ÈźܶàÈË£¬µ¼ÖÂÕâ¸öÎÊÌâµÄÔÒòÆäʵºÜ¼òµ¥£¬Ã¿¸ö¹ú¼Ò(»òÇøÓò)¶¼¹æ¶¨Á˼ÆËã»úÐÅÏ¢½»»»ÓõÄ×Ö·û±àÂ뼯£¬ÈçÃÀ¹úµÄÀ©Õ¹
ASCII Âë, ÖйúµÄ GB2312-80£¬ÈÕ±¾µÄ JIS
µÈ¡£×÷Ϊ¸Ã¹ú¼Ò/ÇøÓòÄÚÐÅÏ¢´¦ÀíµÄ»ù´¡£¬×Ö·û±àÂ뼯Æð×Åͳһ±àÂëµÄÖØÒª×÷Óá£×Ö·û±àÂ뼯°´³¤¶È·ÖΪ
SBCS(µ¥×Ö½Ú×Ö·û¼¯)£¬DBCS( ......