Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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´ò¿ª´íÎóÌáʾ

Èç¹û²»¾ß±¸ÐÞ¸Äphp.iniµÄȨÏÞ£¬¿ÉÒÔÈçÏ£º
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
µ±È»£¬Èç¹ûÄܹ»ÐÞ¸Äphp.iniµÄ»°£¬Èçϼ´¿É£º
display_errors = On
error_reporting  =  E_ALL & ~E_NOTICE ......

40¸ö¼¼ÇÉÓÅ»¯ÄúµÄPHP´úÂë

1. Èç¹ûÒ»¸ö·½·¨Äܱ»¾²Ì¬£¬ÄǾÍÉùÃ÷ËûΪ¾²Ì¬µÄ£¬ËÙ¶È¿ÉÌá¸ß1/4;
2. echoµÄЧÂʸßÓÚprint,ÒòΪechoûÓзµ»ØÖµ£¬print·µ»ØÒ»¸öÕûÐÍ;
3. ÔÚÑ­»·Ö®Ç°ÉèÖÃÑ­»·µÄ×î´ó´ÎÊý£¬¶ø·ÇÔÚÔÚÑ­»·ÖÐ;
4. Ïú»Ù±äÁ¿È¥ÊÍ·ÅÄÚ´æ£¬ÌØ±ðÊÇ´óµÄÊý×é;
5. ±ÜÃâʹÓÃÏñ__get, __set, __autoloadµÈħÊõ·½·¨;
6. requiere_once()±È½ÏºÄ×ÊÔ´;
7. ÔÚ ......

php dateʱ¼ä±¾µØ»¯ÎÊÌ⣨ת£©


½ñÌìÔÚдһ¸ö¶«Î÷ʱ£¬·¢ÏÖʱ¼äÒ»Ö±¶Ô²»ÉÏ£¬date("Y-m-d h:i:s") ×ÜÊÇÓë·þÎñÆ÷ʱ¼ä²î¼¸¸öСʱ£®
Ô­À´´Óphp5.1.0¿ªÊ¼£¬php.iniÀï¼ÓÈëÁËdate.timezoneÕâ¸öÑ¡ÏĬÈÏÇé¿öÏÂÊǹرյÄ
Ò²¾ÍÊÇÏÔʾµÄʱ¼ä£¨ÎÞÂÛÓÃʲôphpÃüÁ¶¼ÊǸñÁÖÍþÖαê׼ʱ¼ä
ºÍÎÒÃǵÄʱ¼ä£¨±±¾©Ê±¼ä£©²îÁËÕýºÃ8¸öСʱ

½â¾ö·½Ê½:

Ò»¡ ......

38ÌõPHP±àÂëÓÅ»¯¼ÓËÙ¼¼ÇÉ

1. ¾¡Á¿²ÉÓôóÁ¿µÄPHPÄÚÖú¯Êý¡£
2. echo ±È print ¿ì¡£
3. ²»Òª°Ñ·½·¨Ï¸·ÖµÃ¹ý¶à£¬×ÐϸÏëÏëÄãÕæÕý´òËãÖØÓõÄÊÇÄÄЩ´úÂ룿
4. ÔÚÖ´ÐÐforÑ­»·Ö®Ç°È·¶¨×î´óÑ­»·Êý£¬²»ÒªÃ¿Ñ­»·Ò»´Î¶¼¼ÆËã×î´óÖµ¡£
5. ×¢ÏúÄÇЩ²»ÓõıäÁ¿ÓÈÆäÊÇ´óÊý×飬ÒÔ±ãÊÍ·ÅÄÚ´æ¡£
6. ²¢·ÇÒªÓÃÀàʵÏÖËùÓеÄÊý¾Ý½á¹¹£¬Êý×éÒ²ºÜÓÐÓá£
7. $row['id']µÄÐ ......

phpÃæÊÔÌâÄ¿(ÒÑ×¢´ð°¸)


¼òÊöÌâ(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 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ