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

JSONÔÚPHPÖеÄÓ¦ÓÃ


¡¡¡¡»¥ÁªÍøµÄ½ñÌ죬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.chenyixin.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 dot com","website":"http:\/\/www.chenyixin.com"}}
¡¡¡¡ÎÒ¶¼ËµÁ˺ÍÐòÁл¯ºÜÏñ£¬Ä㻹²»ÐÅ¡£±àÂëºó¾ÍÒª½âÂ룬PHPÌṩÁËÏàÓ¦µÄº¯Êýjson_decode£¬json_decodeÖ´Ðк󣬽«»áµÃµ½Ò»¸ö¶ÔÏ󣬲Ù×÷ÈçÏ£º
<?php
$arr = array(
'name' => '³ÂÒãöÎ',
'nick' => 'Éî¿Õ',
'contact' => array(
'email' => 'shenkong at qq dot com',


Ïà¹ØÎĵµ£º

phpÖÐsqlÓï¾äµÄÒýºÅÏê½â

Õâ¾ÍÒª´ÓË«ÒýºÅºÍµ¥ÒýºÅµÄ×÷Óý²Æð£º
Ë«ÒýºÅÀïÃæµÄ×ֶλᾭ¹ý±àÒëÆ÷½âÊÍÈ»ºóÔÙµ±×÷HTML´úÂëÊä³ö£¬µ«Êǵ¥ÒýºÅÀïÃæµÄ²»ÐèÒª½âÊÍ£¬Ö±½ÓÊä³ö¡£ÀýÈ磺
$abc='I love u';
echo $abc          //½á¹ûÊÇ:I love u
echo '$abc'        //½á¹ûÊ ......

ʵÀý½²½âphpʵÏÖÖÐÎÄˮӡµÄ´úÂë

ÒÔÏÂÊÇÀûÓÃphpʵÏÖÖÐÎÄˮӡµÄ´úÂë¡£
<?php
Header("Content-type: image/png");      /*֪ͨä¯ÀÀÆ÷,ÒªÊä³öͼÏñ*/
$im       = imagecreate(400 , 300);        /*¶¨ÒåͼÏñµÄ´óС*/
$gray     = Ima ......

¹ØÓÚphpÃæÏò¶ÔÏóµÄ¾²Ì¬±äÁ¿µÄÎÊÌâ


´úÂëÈçÏ£º
<?php
class Book{
    static $num=0;
    public function showme(){
        echo 'ÄúÊǵÚ'.self::$num.'λ·Ã¿Í';
        self::$num++;
     ......

php³£ÓÃÀàÕûÀí

ÔÚʵ¼Ê¿ª·¢¹ý³Ì»á¾­³£»áÓöµ½Ò»Ð©Öظ´µÄ²Ù×÷£¬Èç¹ûÿ´Î¶¼Òª×Ô¼ºÈ¥ÊµÏÖÕâÎÞÒɼÓÖØÁË×Ô¼ºµÄ¹¤×÷Á¿£¬ÏÂÃæ¶ÔһЩ¿ÉÄܾ­³£Óõ½µÄÀà×ö¸öÕûÀí£º
ͼ±í¿â
ÏÂÃæµÄÀà¿â¿ÉÒÔÈÃÄãºÜ¼òµ¥¾ÍÄÜ´´½¨¸´ÔÓµÄͼ±íºÍͼƬ¡£µ±È»£¬ËüÃÇÐèÒªGD¿âµÄÖ§³Ö¡£
pChart - Ò»¸ö¿ÉÒÔ´´½¨Í³¼ÆͼµÄ¿â¡£
Libchart - ÕâÒ²ÊÇÒ»¸ö¼òµ¥µÄͳ¼Æͼ¿â¡£
JpGraph - Ò» ......

PHP±à³Ìˮƽ·Ö¼¶(ת)

˵¾äʵ»°,дÕâ¸öÕæ¹»ÎÞÁĵÄ.±¾À´¿´ÁËijλ´óϺµÄÀàËÆÎÄÕÂ,¸¹·ÌÁ˼¸¾äÒ²¾ÍËãÁË.µ«ÊÇ×òÌìÍíÉÏÓиö¿Í»§ÄÃ×ÅÕâƪÎÄÕÂÎÊÎÒ: ÄãѾµÄ×Ô¼º×ö
Íâ°ü,ÄãË㼸¶ÎPHPer?Ëì¸Ð¾õÄÇƪÎÄÕ¶ÔijЩ°ëͨ²»Í¨Ö®È˵ÄÎóµ¼Ö®Éî.ÎÞ·¨,Ö»ÓÐд´ËÎÄÕ±íÃ÷ÎÒ¶ÔPHPerµÄˮƽÇø·ÖµÄÁ¢³¡.
¹ØÓÚ¾ßÌåÊÕÈëˮƽ,×ܵÄÀ´ËµÒòΪÕ⼸ÄêPHPÅàѵ°àµÄ¼Ó¶à,´óÁ¿PHPÐÂÊÖ¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ