json + js + php ¼òµ¥½»»¥
×î½üÔÚдһ¸ö ǰ̨»ùÓÚ javascript. µÄ¿Í»§¶Ë ·þÎñÆ÷¶ËPHP µÄ·ÖÎöϵͳ¡£
ÔÏȼƻ®Ê¹ÓÃXMLΪÊý¾Ý½»»¥»ù´¡ µ«ÊÇ×îÖÕ»¹ÊÇÑ¡ÓýÏÇáÁ¿¼¶µÄJSON×îΪÊý¾Ý½»»¥»ù´¡¡£
Ê×ÏȽéÉÜjsonµÄ¸ñʽ
json ˵¼òµ¥ÆäʵÊÇÒ»ÖÖÊý¾Ý¸ñʽ ¸ü¼òµ¥µÄ¿ÉÒÔ¿´×ö¼òµ¥µÄÊý×é¡£
ʵÀý £¨Ò»£©
<script>
var jsonArray=[
{"house":["±ðÊû","ÉÌÆ··¿","ƽ·¿"]}
,{"place":["±±¾©\","¸£½¨","ºÓÄÏ"]}
];
jsonArray=eval(jsonArray);
alert(jsonArray[0].house[1]);
</script>
ʵÀý(¶þ)
PHP¶ËÉú³Éjson¸ñʽµÄÊý¾Ý
PHPÌṩÁËÁ½¸öjsonÏà¹ØµÄº¯Êý
json_encode :²úÉújson¸ñʽÊý¾Ý
json_decode £º½âÂëjson¸ñʽÊý¾Ý ±äΪÆÕͨÊý×é
<?
$array=array(
'house'=>array('±ðÊû','ÉÌÆ··¿','ƽ·¿'),
"place"=>array('±±¾©','¸£½¨','ºÓÄÏ')
);
/*
Éú³Éjson¸ñʽ
*/
$json = json_encode($array);
echo $json;
/*
½âÂëjson¸ñʽ
*/
$decode_json=json_decode($json);
var_dump($decode_json);
?>
ת×Ô£ºhttp://163navy.blog.163.com/blog/static/105304086200982595643132/
Ïà¹ØÎĵµ£º
תÑÛ¼äÈýÄê¹ýÈ¥ÁË£¬·¢¾õ×Ô¼º¶¼»¹ÔÚÔµØÌ¤²½£¬Ë×»°Ëµ“ÄæË®ÐÐÖÛ£¬²»½øÔòÍË”£»ÈýÄê¼ä£¬´Óasp£¬javaµ½PHP£¬ÔÚ¼¸ÃÅÓïÑÔÖ®¼äշת£¬
ÿÃŶ¼»áÄÇôһµãµã£¬¾ÍÊDz»¾«Í¨£¬¸Ð¾õÿÑù¶¼ÄDz»´íÊÖ£¬ÏÖÔÚ϶¨¾öÐÄδÀ´ºÜ³¤Ò»¶Îʱ¼äÄÚ¶¼½«·ÖÅ䏸PHP£¬Ò»ÇоʹÓZend Framework¿ò¼Ü¿ªÊ¼°É ......
ÖªµÀ²î¾àÁË£¬Å¬Á¦°É£¡
1. Which of the following will not add john to the users array?
1. $users[] = 'john';
2. array_add($users,'john');
3. array_push($users,'john');
4. $users ||= 'john';
2. What's the difference between sort(), asort() and ksort? Under what circumstances would you use each o ......
±ÈÈçÒª¸øÓû§±¨¸æÒ»¸ö´íÎó£¬ÓÃÏÂÃæµÄ·½·¨£º
ʹÓÃset_error_handlerÉèÖÃ×Ô¼ºµÄ´íÎó´¦Àíº¯Êý£¬ÔÚ±¨´íµÄµØ·½Ê¹ÓÃtrigger_error£¬ÔÚ×Ô¶¨ÒåµÄ´íÎó´¦Àíº¯ÊýÖиøÓû§ÏÔʾһ¸ö³ö´íÐÅÏ¢Ò³Ãæ¡£
µ«
ÊÇÈç¹ûµ÷ÓÃtrigger_errorµÄÕâ¸öÒ³ÃæÊDZ»Ò»´ÎajaxÇëÇó´¥·¢µÄ£¬ÄÇôajax·µ»Øºó½«µÃµ½Ò»´ó¶ÑÓÃÓÚÏÔʾ´íÎóµÄhtml´úÂë¡£¶øÒ»°ã
ajaxµ÷Óö ......
³õѧPHPµÄʱºò£¬ÎÒÃǾ³£±»PHPµÄ¾ø¶Ô·¾¶ºÍÏà¶Ô·¾¶ÅªµÄÔÎͷתÏò¡£Â·¾¶ÎÊÌâ¾³£µ¼ÖÂinclude¼°requireÃüÁî²»ÄܼÓÔØµ½Ö¸¶¨µÄÒ³
Ãæ£¬´Ó¶øµ¼ÖÂWeb³ÌÐòÔËÐдíÎó¡£±¾ÎĽ«¸ú´ó¼ÒÒ»Æð̽ÌÖÒ»ÏÂPHP·¾¶ÎÊÌâµÄ³£Óýâ¾ö·½°¸¡£
ÏÂÃæÎÒÃÇÏÈ×öÒ»¸ö¸ö¼òµ¥µÄʾÀý:
ÉÏͼÊÇÒ»¸ö¼òµ¥WebÏîÄ¿µÄ½á¹¹Í¼,ÆäÖи÷ÎļþµÄ´úÂëÈçÏÂ: ......
<?php
//¶ÔÏó
class MyJson{
$id=1;
$site ......