PHPÖÐJSONµÄÓ¦ÓÃ
»¥ÁªÍøµÄ½ñÌ죬AJAXÒѾ²»ÊÇʲôİÉúµÄ´Ê»ãÁË¡£ËµÆðAJAX£¬¿ÉÄÜ»áÁ¢¼´ÏëÆðÒòRSS¶øÐËÆðµÄXML¡£XMLµÄ½âÎö£¬¿ÖÅÂÒѾ²»ÊÇʲôÄÑÌâÁË£¬ÌرðÊÇPHP5£¬´óÁ¿µÄXML½âÎöÆ÷µÄÓ¿ÏÖ£¬Èç×îÇáÁ¿¼¶µÄSimpleXML¡£²»¹ý¶ÔÓÚAJAXÀ´Ëµ£¬XMLµÄ½âÎö¸üÇãÏòÓÚǰ̨JavascriptµÄÖ§³Ö¶È¡£ÎÒÏëËùÓнâÎö¹ýXMLµÄÈË£¬¶¼»áÒòÊ÷ºÍ½Úµã¶øÍ·´ó¡£²»¿É·ñÈÏ£¬XMLÊǺܲ»´íµÄÊý¾Ý´æ´¢·½Ê½£¬µ«ÊÇÆäÁé»îÇ¡Ç¡Ôì³ÉÁËÆä½âÎöµÄÀ§ÄÑ¡£µ±È»£¬ÕâÀïËùÖ¸µÄÀ§ÄÑ£¬ÊÇÏà¶ÔÓÚ±¾ÎĵÄÖ÷½Ç££JSON¶øÑÔ¡£
JSONΪºÎÎÎҾͲ»Öظ´¸ÅÄîÁË¡£Í¨Ë×µÄ˵£¬ËüÊÇÒ»ÖÖÊý¾ÝµÄ´æ´¢¸ñʽ£¬¾ÍÏñPHPÐòÁл¯ºóµÄ×Ö·û´®Ò»Ñù¡£ËüÊÇÒ»ÖÖÊý¾ÝÃèÊö¡£±ÈÈçÎÒÃǽ«Ò»¸öÊý×éÐòÁл¯ºó´æ·Å£¬¾Í¿ÉÒÔºÜÈÝÒ׵ķ´ÐòÁл¯ºóÓ¦Óá£JSONÒ²ÊÇÈç´Ë£¬Ö»²»¹ýËû´î½¨µÄÊÇ¿Í»§¶ËJavascriptºÍ·þÎñ¶ËPHPµÄ½»»¥ÇÅÁº¡£ÎÒÃÇÓÃPHPÉú³ÉJSONºóµÄ×Ö·û´®£¬È»ºó°ÑÕâ¸ö×Ö·û´®´«¸øǰ̨Javascript£¬Javascirpt¾Í¿ÉÒÔºÜÈÝÒ׵Ľ«Æä·´JSONÈ»ºóÓ¦Óá£ËµÍ¨Ë׵㣬ËüÕæµÄºÜÏñÊý×é¡£
ÑÔ¹éÕý´«£¬ÈçºÎʹÓÃJSON¡£PHP5.2¿ªÊ¼ÄÚÖÃÁËJSONµÄÖ§³Ö¡£µ±È»£¬Èç¹ûµÍÓÚÕâ¸ö°æ±¾µÄ»°£¬ÄÇôÊÐÃæÉÏÓкܶàPHP°æ±¾µÄʵÏÖ£¬Ëæ±ãÏÂÒ»¸öÓþÍOKÀ²¡£ÏÖÔÚÖ÷ÒªÊÇ˵˵PHPÄÚÖÃÖ§³ÖµÄJSON¡£ºÜ¼òµ¥£¬Á½¸öº¯Êý£ºjson_encodeºÍjson_decode£¨¸úÐòÁл¯ºÜÏñÀ²£©¡£Ò»¸ö±àÂ룬һ¸ö½âÂë¡£ÏÈ¿´¿´±àÂëµÄʹÓãº
<?php
$arr = array(
'name' => '³ÂÒãöÎ',
'nick' => 'Éî¿Õ',
'contact' => array(
'email' => 'shenkong at qq dot com',
'website' => 'http://www.chinaz.com',
)
);
$json_string = json_encode($arr);
echo $json_string;
?>
ºÜ¼òµ¥µÄ½«Ò»¸öÊý×éJSONÁË¡£ÐèÒªÖ¸³öµÄÊÇ£¬ÔÚ·ÇUTF-8±àÂëÏ£¬ÖÐÎÄ×Ö·û½«²»¿É±»encode£¬½á¹û»á³öÀ´¿ÕÖµ£¬ËùÒÔ£¬Èç¹ûÄãʹÓÃgb2312±àдPHP´úÂ룬ÄÇô¾ÍÐèÒª½«°üº¬ÖÐÎĵÄÄÚÈÝʹÓÃiconv»òÕßmbתΪUTF-8ÔÙ½øÐÐjson_encode£¬ÉÏÃæÊä³ö½á¹ûÈçÏ£º
{"name":"\u9648\u6bc5\u946b","nick":"\u6df1\u7a7a","contact":{"email":"shenkong at qq
Ïà¹ØÎĵµ£º
×ÛºÏÍøµêϵͳÊÇÓÉEÒ×ÍøÂç(68ws.cn)»ùÓÚphp+mysql¿ª·¢£¬¼æÈݸ÷ÀàÉÌÆ·µÄ·¢²¼¡¢Õ¹Ê¾ºÍ¶©¹º¡£³ýÁ˾ßÓÐÍêÉƵÄÉÌÆ·ÀàÐ͹ÜÀí¡¢ÉÌÆ·¹ÜÀí¡¢ÅäËÍÖ§¸¶¹ÜÀí¡¢¶©µ¥¹ÜÀí¡¢»áÔ±·Ö×é¡¢»áÔ±¹ÜÀí¡¢²éѯͳ¼ÆºÍ¶àÏîÉÌÆ·´ÙÏú¹¦ÄÜ£¬»¹¾ßÓÐÍêÕûµÄÎÄÕ¡¢Í¼ÎÄ¡¢ÏÂÔØ¡¢µ¥Ò³¡¢¹ã¸æ·¢²¼µÈÍøÕ¾ÄÚÈݹÜÀí¹¦ÄÜ¡£ÏµÍ³¾ßÓо²Ì¬HTMLÉú³É¡¢UTF-8¶àÓïÑÔÖ§³ ......
ÊÖ»úÍøµê¹ÜÀíϵͳÊÇÓÉEÒ×ÍøÂç(68ws.cn)»ùÓÚphp+mysql¿ª·¢£¬¾ßÓÐÍêÉƵÄÉÌÆ·ÀàÐ͹ÜÀí¡¢ÉÌÆ·¹ÜÀí¡¢ÅäËÍÖ§¸¶¹ÜÀí¡¢¶©µ¥¹ÜÀí¡¢»áÔ±·Ö×é¡¢»áÔ±¹ÜÀí¡¢²éѯͳ¼ÆºÍ¶àÏîÉÌÆ·´ÙÏú¹¦ÄÜ£»¾ßÓÐÆ·ÅÆÑ¡»ú¡¢ÊÖ»ú²ÎÊýרÓÃÊäÈë½çÃæµÈÊÖ»úÏúÊÛÍøÕ¾µÄÌØÉ«¹¦ÄÜ¡£ÏµÍ³¾ßÓо²Ì¬HTMLÉú³É¡¢UTF-8¶àÓïÑÔÖ§³Ö¡¢¿ÉÊÓ»¯Ä£°æÒýÇæµÈ¼¼ÊõÌص㣬ÊʺÏÏúÊÛ ......
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/01/28/1-4/
Ç°ÎĽéÉÜÁËPHPµÄÓïÑÔ¹¹³ÉÓ빤×÷ÔÀí£¬½ÓÏÂÀ´Õýʽ½éÈëPHPµÄÓï·¨¡£
ÔÚPHPÖУ¬»ù±¾Êý¾Ý¿É·ÖΪ³£Á¿ºÍ±äÁ¿Á½ÖÖ¡£¶øphpµÄ³£Á¿ºÍ±äÁ¿Ãûͨ³£³ÆΪ±êʶ·û¡£
ÐèҪעÒâµÄÊDZêʶ·û±ØÐëÒÔ×Öĸ»òÕßÏ»®Ïß¿ªÍ·£¬²¢ÇÒÖ»ÄÜ°üÀ¨×Öĸ¡¢Êý×ÖºÍÏ»®Ïß¡£
³£Á¿µÄ ......
תÔØ×Ô£ºhttp://hi.baidu.com/thinkinginlamp/blog/item/5da6905211f719050df3e356.html
×÷ÕߣºÀÏÍõ
×îÀõķ½·¨¾ÍÊÇͨ¹ý$_FILES[...]['type']À´¼ì²âÉÏ´«ÎļþµÄÀàÐÍ£¬ÒòΪֻÐè¼òµ¥ÐÞ¸ÄÎļþÀ©Õ¹Ãû¾Í¿ÉÒÔαÔìËü¡£
ÁíÒ»¸öÏà¶Ô°²È«µãµÄ·½·¨ÊÇͨ¹ýÎļþÍ·Á½¸ö×Ö½ÚµÄÄÚÈÝÀ´ÅжÏÉÏ´«ÎļþµÄÀàÐÍ£¬Àý×Ó´úÂëÈçÏ£º
01 $handle = fop ......