dz̸ÓÃphp¶Ôunicodeתutf 8±àÂë
(IT°ØÀͼ Ô´´ÎÄÕÂ)Èç¹ûÖ»ÊÇunicodeתutf-8±àÂëµÄËã·¨£¬ÍøÉϵ½´¦¶¼ÊÇÁË£¬²»¹ýºÜ¶àÈËÒ²ÊÇÄã³ÎÒ£¬ÎÒ³Ä㣬¸ù±¾¾Í²»Àí½âwhyºÍdo£¬±¾ÎijýÁ˸ø³ö×î¼òµ¥µÄphp¶Ôunicodeתutf-8±àÂ뺯ÊýÖ®Í⣬ҲÉîÈëÌÖÂÛÁËÕâÁ½ÖÖ±àÂëµÄ¹Øϵ£¬Àí½âºÃÁ˻ᷢÏÖÍøÉÏһЩ¾ÉµÄ¶«Î÷£¬ÊÇÑÏÖضàÓà¼æ¹ýÆڵģ¬ÒòΪ´Óutf-8Á÷ÐпªÊ¼µ½ÏÖÔÚ£¬ÔçÒѾÓÉÔÀ´Áù×ֽڿɱä±àÂ뵽ʵ¼ÊÍêÈ«¾ÓÓÚunicode(UCS-2)µÄÎȶ¨½×¶Î¡£
unicode±àÂëÊÇʵÏÖutf-8ÓëgbϵÁбàÂë(gb2312¡¢gbk¡¢gb18030)ת»»µÄ»ù´¡£¬ËäÈ»ÎÒÃÇÒ²¿ÉÒÔÖ±½Ó×öÒ»¸öutf-8µ½ÕâЩ±àÂëµÄ¶ÔÕÕ±í£¬µ«ºÜÉÙÓÐÈË»áÕâô×ö£¬ÒòΪutf-8µÄ¿É±ä±àÂë¾ßÓв»È·¶¨ÐÔ£¬Òò´ËÒ»°ãÇé¿öʹÓö¼ÊÇunicodeÓëgb±àÂëµÄ¶ÔÕÕ±í£¬unicode(UCS-2)ʵ¼ÊÉÏÊÇutf-8µÄ»ù´¡±àÂ룬utf-8Ö»ÊÇËüµÄÒ»ÖÖʵÏÖ¶øÒÑ£¬Á½Õß´æÔÚÏÂÃæµÄ¶ÔÓ¦¹Øϵ£º
Unicode·ûºÅ·¶Î§ | UTF-8±àÂ뷽ʽ
u0000 0000 - u0000 007F | 0xxxxxxx
u0000 0080 - u0000 07FF | 110xxxxx 10xxxxxx
u0000 0800 - u0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
ÓÉÓÚÄ¿Ç°utf-8ʹÓõÄ×Ö·û¶¼ÊǾÓÓÚUCS-2µÄ£¬Òò´Ë¶ÔÓÚ4-6×Ö½Ú±àÂëµÄÇé¿öÊDz»±Ø¿¼Âǵģ¬Í¬ÑùµØ£¬ÔÚ·´Ïòת»»µÄʱºò£¬Èç¹û³öÏÖËÄ×Ö½ÚÒÔÉϵÄutf-8×Ö·û£¬¿ÉÒÔÖ±½ÓÊÓΪÂÒÂëºöÂÔµô»òתΪunicodeʵÌåÐÎʽ("&#long int;"ÐÎʽ)£¬È»ºó½»¸øä¯ÀÀÆ÷»òÏà¹Ø½âÎö³ÌÐòÈ¥´¦Àí£¬ÓÃphp°ÑunicodeתΪutf-8±àÂëµÄËã·¨ÈçÏ£º
/*
* ²ÎÊý $c ÊÇunicode×Ö·û±àÂëµÄintÀàÐÍÊýÖµ£¬Èç¹ûÊÇÓöþ½øÖƶÁÈ¡µÄÊý¾Ý£¬ÔÚphpÖÐͨ³£ÒªÓà hexdec(bin2hex( $bin_unichar )) ÕâÑùת»»
*/
function uni2utf8( $c )
{
if ($c < 0x80)
{
$utf8char = chr($c);
}
else if ($c < 0x800)
{
$utf8char = chr(0xC0 | $c >> 0x06).chr(0x80 | $c & 0x3F);
}
else if ($c < 0x10000)
{
$utf8char = chr(0xE0 | $c >> 0x0C).chr(0x80 | $c >> 0x06 & 0x3F).chr(0x80 | $c & 0x3F);
}
//ÒòΪUCS-2Ö»ÓÐÁ½×Ö½Ú£¬ËùÒÔºóÃæµÄÇé¿öÊDz»¿ÉÄܳöÏֵģ¬ÕâÀïÖ»ÊÇ˵Ã÷unicode HTMLʵÌå±àÂëµ
Ïà¹ØÎĵµ£º
Èç¹û²»¾ß±¸ÐÞ¸Äphp.iniµÄȨÏÞ£¬¿ÉÒÔÈçÏ£º
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
µ±È»£¬Èç¹ûÄܹ»ÐÞ¸Äphp.iniµÄ»°£¬Èçϼ´¿É£º
display_errors = On
error_reporting = E_ALL & ~E_NOTICE ......
¡¡¡¡×î½üÔÚ×ö¸öÒ³Ãæʱ£¬Óöµ½ÒªPHP³ÌÐòÖÐʵÏÖÑÓ³Ùµ±Ç°½ø³ÌÎÊÌâ¡£ÓÉÓÚ½Ó´¥PHPʱ¼äÓÐÏÞ£¬Ï뵱ȻµÄÈÏΪPHPÖÐʵÏִ˹¦Äܵĺ¯ÊýÒ²ÊÇsleep()¡£ÊÂʵÉÏ£¬ÔÚPHPÖеÄÈ·ÓÐÕâ¸öº¯Êý£¬µ«ÔÚÎÒ³¢ÊÔÁË°ëÌìºó£¬È´Ê¼ÖÕ²»ÄÜʵÏÖÎÒÒªµÄÂß¼¡£PHP5ÊÖ²áÖУ¬¶ÔÕâ¸öº¯ÊýÊÇÕâÑùÃèÊöµÄ£ºsleep -- Delay execution¡£µ±ÎÒ°Ù¶ÈÁËÒԺ󣬲ÅÖªµÀÕ⸠......
1. дһ¸öº¯Êý£¬¾¡¿ÉÄܸßЧµÄ£¬´ÓÒ»¸ö±ê×¼ url
ÀïÈ¡³öÎļþµÄÀ©Õ¹Ãû
ÀýÈç: http://www.sina.com.cn/abc/de/fg.php
?id=1
ÐèҪȡ³ö php »ò .php
2. ÔÚ HTML ÓïÑÔÖУ¬Ò³ÃæÍ·²¿µÄ meta ±ê¼Ç¿ÉÒÔÓÃÀ´Êä³öÎļþµÄ±àÂë
¸ñʽ£¬ÒÔÏÂÊÇÒ»¸ö±ê×¼µÄ meta Óï¾ä
<META http-equiv='Content-Type
' ......
¼òÊöÌâ(50·Ö)()
1¡¢ÓÃPHP´òÓ¡³öÇ°Ò»ÌìµÄʱ¼ä¸ñʽÊÇ2006-5-10 22:21:21(2·Ö)
echo date('Y-m-d H:i:s', strtotime('-1 day'));
»òÕß
$yesterday = time() - (24 * 60 * 60);
echo 'today:'.date('Y-m-d H:i:s')."\n";
echo 'yesterday:'. date('Y-m-d H:i:s', $yesterday)."\n";
2¡¢echo(),pr ......