php json ajax
¡¡»¥ÁªÍøµÄ½ñÌ죬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' => '³ÂÒãöÎ'
Ïà¹ØÎĵµ£º
1.´ò¿ªÎҵĵçÄÔ£¬½øÈëDÅÌ£¬ÔÚÆäÏÂн¨Ò»¸öÎļþ¼Ð£¬ÃûΪ local ¡£
2.µ½Æä¹Ù·½Õ¾µãÏÂÔØ apache_2.2.4-win32-x86-no_ssl.msi ²¢Ö´ÐС£
3.°´3´ÎNext°´Å¥£¬°²×°³ÌÐòÒªÇóÊäÈëÄãµÄNetwork Domain£¨ÍøÂçÓòÃû£©¡¢Server Domain£¨·þÎñÆ÷ÓòÃû£©ºÍÍøÕ¾¹ÜÀíÔ±µÄE-mail£¬ÓеĻ°¾ÍÈçʵÌîд£¬±¾ËµÃ÷½éÉܵÄÊDZ¾µØ×Ô½¨²âÊ ......
1.
error_reporting(E_ERROR | E_WARNING | E_PARSE); //±¨´í¼¶±ð
@set_time_limit(1000); //ÉèÖú¯ÊýÖ´ÐеÄ×î´óʱ¼ä
set_magic_quotes_runtime(0); //ΪÁË°²È«
define('IN_COMSENZ', TRUE);
define('ROOT_PATH', dirname(__FILE__).'/../');   ......
php ʹÓÃÃüÁîÐÐ×Ô±äÁ¿
ÔÚÃüÁîÐÐÀïÊäÈë³ÌÐò²ÎÊýÀ´¸ü¸ÄÆäÔËÐз½Ê½ÊǺܳ£¼ûµÄ×ö·¨¡£ÄãÒ²¿ÉÒÔ¶ÔCLI³ÌÐòÕâÑù×ö¡£PHP
CLI´øÓÐÁ½¸öÌØÊâµÄ±äÁ¿£¬×¨ÃÅÓÃÀ´´ïµ½Õâ¸öÄ¿µÄ£ºÒ»¸öÊÇ$argv±äÁ¿£¬Ëüͨ¹ýÃüÁîÐаѴ«µÝ¸øPHP½Å±¾µÄ²ÎÊý±£´æΪµ¥¶ÀµÄÊý×éÔªËØ£»ÁíÒ»¸ö
ÊÇ$argc±äÁ¿£¬ËüÓÃÀ´±£´æ$argvÊý×éÀïÔªËصĸöÊý¡£
ÓÃ ......
import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte ......