phpºÍjavascriptͨѶ
°ÑphpÊý¾Ý»òÖµ´«µÝ¸øjs
£ººÜ¼òµ¥£¬Ö±½ÓÔÚjsÖÐʹÓÃphp´úÂ룬»ì±à¼´¿É¡£
°ÑjsÊý¾Ý´«µÝ¸øphp
£º¿ÉÒÔʹÓôò¿ªÐ´°¿ÚµÄ·½Ê½£¬Í¨¹ýurlµØÖ·°ÑÊý¾Ý´«µÝ¹ýÈ¥¡£Ò²¿ÉÒÔʹÓÃajax£¬Í¨¹ýget»òpost´«µÝ¸øphp£¬Ò²¿ÉÒÔ±£´æcookieÈÃphpÀ´¶Á¡£
ÔÚ´«µÝÊý¾Ý¹ý³ÌÖпÉÄÜÓöµ½ÖÐÎıàÂë
ÎÊÌ⣬¿ÉÒÔͳһ±àÂ뷽ʽΪjsµÄescape£¬unescape£¬Ò²¿ÉÒÔͳһ±àÂ뷽ʽΪurlencode£¬urldecode
ÓÉÓÚphpÓк¯Êýurlencode£¬urldecode£¬Õâ¸öʱºòÐèÒªjsÀ´ÊµÏָñàÂ룬ÏÂÃæÊÇjsµÄ±àÂë
function UrlEncode(str)
{
var ret="";
var strSpecial="!\"#$%&()*+,/:;<=>?[]^`{|}~%"; var tt="";
for(var i=0;i<str.length;i++)
{
var chr = str.charAt(i);
var c=str2asc(chr);
tt += chr+":"+c+"n";
if(parseInt("0x"+c) > 0x7f)
{
ret+="%"+c.slice(0,2)+"%"+c.slice(-2);
}
else
{
if(chr==" ")
ret+="+";
else if(strSpecial.indexOf(chr)!=-1)
ret+="%"+c.toString(16);
else
ret+=chr;
}
}
return ret;
}
UrlDecode
function UrlDecode(str){
var ret="";
for(var i=0;i<str.length;i++)
{
var chr = str.charAt(i);
if(chr == "+")
{
ret+=" ";
}
else if(chr=="%")
{
var asc = str.substring(i+1,i+3);
if(parseInt("0x"+asc)>0x7f)
{
ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6)));
i+=5;
}
else
{
ret+=asc2str(parseInt("0x"+asc));
i+=2;
}
}
else
{
ret+= chr;
}
}
return ret;
}
ÓÉÓÚjsÓк¯ÊýescapeºÍunecapse£¬ÐèÒªphpÀ´ÊµÏָñàÂ룬ÏÂÃæÊ
Ïà¹ØÎĵµ£º
Jsѧϰ£¨ËÄ£©
Èç¹ûµ±Ç°ÕýÔÚÖ´ÐеÄÊÇÒ»¸ö·½·¨£¬ÔòÖ´ÐÐÉÏÏÂÎľÍÊǸ÷½·¨Ëù¸½ÊôµÄ¶ÔÏó£¬Èç¹ûµ±Ç°ÕýÔÚÖ´ÐеÄÊÇÒ»¸ö´´½¨¶ÔÏ󣨾ÍÊÇͨ¹ý new À´´´½¨£©µÄ¹ý³Ì£¬Ôò´´½¨µÄ¶ÔÏó¾ÍÊÇÖ´ÐÐÉÏÏÂÎÄ¡£
Èç¹ûÒ»¸ö·½·¨ÔÚÖ´ÐÐʱûÓÐÃ÷È·µÄ¸½ÊôÓÚÒ»¸ö¶ÔÏó£¬ÔòËüµÄÖ´ÐÐÉÏÏÂÎÄÊÇÈ«¾Ö¶ÔÏ󣨶¥¼¶¶ÔÏ󣩣¬µ«Ëü²»Ò»¶¨¸½ÊôÓÚÈ«¾Ö¶ÔÏó¡£È«¾Ö¶ÔÏóÓɵ±Ç°» ......
Õ⼸ÌìÔÚѧJavaScriptµÄ»ù´¡ÖªÊ¶£¬¾Í°Ñ»ù´¡µÄ֪ʶÕûÀíһϡ£
1¡¢JavaScriptµÄËÄÖÖ»ù±¾µÄÊý¾ÝÀàÐÍ£ºÊýÖµ£¨ÕûÊýºÍʵÊý£©¡¢×Ö·û´®ÐÍ£¨ÓÓ”»òÕß‘’À¨ÆðÀ´µÄ×Ö·û»òÕßÊýÖµ£©¡¢²¼¶ûÐÍ£¨true»òfalse£©¡¢¿ÕÖµ¡£
2¡¢JavaScriptµÄ±äÁ¿
ÉùÃ÷±äÁ¿£º±äÁ¿Ôڽű¾ÖеÚÒ»´Î³öÏÖʱºòÔÚÉùÃ÷ÖУ¨var£©£¬±äÁ¿µÄ ......
JSÖÐÊý×éµÄÅúÁ¿Ìî³ä·½Ê½:
1.ÔÚÉùÃ÷ʱͬʱ½øÐÐÌî³ä
var beatles = Array("John","Paul","George","Ringo");
2.ÎÒÃÇÉõÖÁÓò»×ÅÃ÷È·µØ±íÃ÷ÎÒÃÇÊÇÔÚ´´½¨Êý×é.ÊÂʵÉÏ,Ö»ÐèÓÃÒ»¶Ñ·½À¨ºÅÀ¨ÆðÀ´¾Í×ãÒÔ´´½¨ÎÒÃÇÏëÒªµÄÊý×éÁË:
......
±¾À´²»Ïë̸Õâ¸ö³ÁÖصĻ°Ì⣬Æäʵ˵°×ÁË£¬Èç¹ûÄãÒ»¸öPHPµÄ³ÌÐòÔ±Á¬ÔõôÅäÖû·¾³¶¼¸ã²»¶¨Ä㻹¸ã¸öP¿ª·¢Ñ½¡£µÃ£¬ÔÛ²»ËµÄãÔÚlinuxÏÂÃæ¸ã¶¨ÕâЩ£¬ÄѵÀÄãÔÚwindowsÏÂÃæÄãÒ²¸ã²»¶¨£¿
ÏÖÔÚµÄPHP¶þ½øÖÆ°²×°°æ±¾ÒѾ¿ÉÒÔÖ§³Öapache,iis5,iis6µÈһЩWEB·þÎñÆ÷ÁË£¬ÎªÊ²Ã´»¹ÊÇÓÐһЩÈ˲»»áÅäÖÃÄØ£¿ÕæÏ벻ͨѽ¡£¡£¡£¡£¡£¡£
ÓÚÊÇÔÚÕâÖÖ´ó ......