phpÓëjavascriptÖ®¼ä±äÁ¿ÒýÓÃÎÊÌâ
JavaScript ==> PHP£º
·½·¨Ò»: ÏÈÓÃPHPÉú³Éjs´úÂ룬Ȼºóͨ¹ýä¯ÀÀÆ÷µÄ×Ô¶¯Ë¢Ð£¬½«javascript±äÁ¿´«µÝµ½PHP½Å±¾ÖС£
×¢Ò⣺ÔÚʵ¼ÊÓ¦ÓÃÖÐÒª·ÀÖ¹Óû§ÔÚµØÖ·À¸ÄÚ¸ü¸Ä´«µÝµÄ±äÁ¿Öµ¡£
<?php
if($qq) echo $qq.'<br>';
else echo "<script language='javascript'>var qq='ÎÒµÄQQÊÇ1234567'; location.href='?qq='+qq; </script>";
echo $qq;
?>
·½·¨¶þ£ºÏÈÓÃdocument.cookie·½·¨°Ñjs±äÁ¿Ð´ÈëcookieÖУ¬ÔÙÓÃPHPÈ¡³ö¡£
<script language="javascript" type="text/javascript">
var name = "myqq",value="10000";
document.cookie = name+" = "+value+";"
</script>
<?php
echo $_COOKIE["myqq"]."<br/>";
$my = "ÎÒµÄQQÊÇ".$_COOKIE["myqq"];
echo $my;
?>
·½·¨Èý£º
<script>
var a = 'ÎÒÊÇÐñÈÕ£¡';
</script>
<?php
$c = "<script>document.write(a);</script>";
echo $c;
?>
PHP ==> JavaScript £º
//·½·¨Ò»£ºÒÔhtmlΪý½é, php±äÁ¿-->html¶ÔÏó-->javascriptµ÷Óá£
<?php
$val_overview_pic = "ÎÒÊÇÐñÈÕ£¡";
?>
<input type="hidden" name="did" value="<?=$val_overview_pic;?>">
<script language="javascript" type="text/javascript">
alert(did.value);
//window.location ="/topic/isoktoshow.php?pic="+did.value;
</script>
·½·¨¶þ£ºÓÃphpÊéдjavascript¡£
<?php
$val_overview_pic = "/pic/pic1.jpg";
echo "<script language='javascript' type='text/javascript'>";
echo " alert('".$val_overview_pic."');";
//echo " window.location ='/topic/isoktoshow.php?pic='".$val_overview_pic ."';";
echo "</script>";
?>
Ïà¹ØÎĵµ£º
1¡¢²¼¶ûÖµ£ºfalse(0,¿Õ°×,null); true(-1,·Ç0Öµ)£» 2¡¢echo '$s'Êä³öÄÚÈÝÊÇ $s;
Èç¹û""ÀïÃæ°üº¬ÁË$s»òÕß{$s}£¬ÄÇô½«ÏÔʾµÄ±äÁ¿µÄÖµ¡£ÍƼöʹÓÃ{$s}µÄ·½Ê½¡£
ʹÓÃ""ʱºò£¬Èç¹ûÔÚ""ÀïÃ滹ҪʹÓÃ"",¾Í±ØÐëÓÃ\À´×ªÒå,ÀýÈ磺 echo "\"sss\""; 3¡¢ ......
µÚ3ÕÂ ¶ÔÏó
JavaScriptµÄ¼òµ¥ÀàÐÍ°üÀ¨Êý×Ö¡¢×Ö·û´®¡¢²¼¶ûÖµ£¨trueºÍfalse£©¡¢nullÖµºÍundefinedÖµ¡£ÆäËûËùÓеÄÖµ¶¼ÊǶÔÏó¡£Êý×Ö¡¢×Ö·û´®ºÍ²¼¶ûÖµ“òËÆ”¶ÔÏó£¬ÒòΪËüÃÇÓµÓз½·¨£¬µ«ËüÃÇÊDz»¿É±äµÄ¡£JavaScriptÖеĶÔÏóÊǿɱäµÄ¼ü-Öµ¼¯ºÏ(keyed collections)¡£ÔÚJavaScriptÖУ¬Êý×éÊǶÔÏ󣬺¯ÊýÊǶÔÏó£¬Õý ......
¿Í»§¶Ëä¯ÀÀÆ÷²»Ö§³Öµ±Ç°JavaScript½Å±¾´æÔÚÈçÏÂÈýÖÖ¿ÉÄÜ£º
¿Í»§¶Ëä¯ÀÀÆ÷²»Ö§³ÖÈκÎJavaScript½Å±¾£»
¿Í»§¶Ëä¯ÀÀÆ÷Ö§³ÖµÄJavaScript½Å±¾°æ±¾Óë¸Ã½Å±¾´úÂëʹÓõİ汾ËùÖ§³ÖµÄ¶ÔÏó¡¢ÊôÐÔ»ò·½·¨²»Í¬£»
¿Í»§¶ËΪÁË°²È«Æð¼û£¬ÒѾ½«ä¯ÀÀÆ÷¶ÔJavaScript½Å±¾µÄÖ§³ÖÉèÖÃΪ½ûÖ¹¡£
ÒÔÉÏÈýÖÖÇé¿ö×ܽáÆðÀ´£¬¾ÍÊÇä¯ÀÀÆ÷¶ ......
ÔÚPHPÖÐʹÓùýSESSIONµÄÅóÓÑ¿ÉÄÜ»áÅöµ½Õâôһ¸öÎÊÌ⣬SESSION±äÁ¿²»ÄÜ¿çÒ³´«µÝ¡£ÕâÁîÎÒ¿àÄÕÁ˺ÃЩÈÕ×Ó£¬×îÖÕͨ¹ý²é×ÊÁÏ˼¿¼²¢½â¾öÁËÕâ¸öÎÊÌâ¡£ÎÒÈÏΪ£¬³öÏÖÕâ¸öÎÊÌâµÄÔÒòÓÐÒÔϼ¸µã£º
1¡¢¿Í»§¶Ë½ûÓÃÁËcookie
2¡¢ä¯ÀÀÆ÷³öÏÖÎÊÌ⣬ÔÝʱÎÞ·¨´æÈ¡cookie
3¡¢php.iniÖеÄsession.use_trans_sid = 0»òÕß±àÒëʱûÓÐ ......