PHPѧϰ֮ PHP ÔËËã·û
ÔËËã·ûÓÃÓÚ¶ÔÖµ½øÐÐÔËËã.
PHP ÔËËã·û
±¾²¿·ÖÁгöÁËÔÚ PHP ÖÐʹÓõĸ÷ÖÖÔËËã·û£º
ËãÊýÔËËã·û
ÔËËã·û˵Ã÷Àý×Ó½á¹û
+
Addition
x=2
x+2
4
-
Subtraction
x=2
5-x
3
*
Multiplication
x=4
x*5
20
/
Division
15/5
5/2
3
2.5
%
Modulus (division remainder)
5%2
10%8
10%2
1
2
0
++
Increment
x=5
x++
x=6
--
Decrement
x=5
x--
x=4
¸³ÖµÔËËã·û
ÔËËã·û˵Ã÷Àý×Ó
=
x=y
x=y
+=
x+=y
x=x+y
-=
x-=y
x=x-y
*=
x*=y
x=x*y
/=
x/=y
x=x/y
.=
x.=y
x=x.y
%=
x%=y
x=x%y
±È½ÏÔËËã·û
ÔËËã·û˵Ã÷Àý×Ó
==
is equal to
5==8 returns false
!=
is not equal
5!=8 returns true
>
is greater than
5>8 returns false
<
is less than
5<8 returns true
>=
is greater than or equal to
5>=8 returns false
<=
is less than or equal to
5<=8 returns true
Âß¼ÔËËã·û
ÔËËã·û˵Ã÷Àý×Ó
&&
and
x=6
y=3
(x < 10 && y > 1) returns true
||
or
x=6
y=3
(x==5 || y==5) returns false
!
not
x=6
y=3
!(x==y) returns true
Ïà¹ØÎĵµ£º
Ò»Ö±ÈÏΪphpÖÐ×Ö×Ö·û´®±È½ÏÖ±½ÓÓÃ==À´Åжϻ¹ÊǺܷ½±ãµÄ,µ«½ñÌìÓöµ½µÄÒ»¸öÎÊÌâ,³¹µ×ÈÃÎÒÃ÷°×ÁËʹÓÃstrcmpµÄ±ØÒªÐÔ.Õâ¸öÎÊÌâºÜ¶àÀÏÊÖ¶¼¿ÉÄÜ»áºöÂÔµÄ.
½ñÌìÔڵǼ×Ô¼º×öµÄ³ÌÐòʱ,ÔÚÊäÈëÑéÖ¤Âëºó,ÏëÖ±½Ó°´Ð¡¼üÅÌÉϻسµµÇ¼(³ÌÐò¼ì²éÁ˻سµÊ¼þ)£¬½á¹û°´»Ø³µ°´³ÉÁ˼üÅÌÉϻسµ¼üÅÔ±ßСÊýµÄÄǸö¼ü,ÑéÖ¤ÂëÀ¸¾Í¶àÊäÈëÁËÒ»¸öµã¡£ÓÉÓÚ ......
¡¡sessionÊÇÍøÕ¾±£´æÓû§ÐÅÏ¢µÄÒ»ÖÖÊֶΣ¬Ó¦ÓÃÏ൱¹ã·º¡£ÀýÈçµÚÎå½ìÅÅÐаñ¾ÍʹÓÃÁËsession¡£¾¹ý¶ÔµÚÎå½ìÅÅÐаñµÄÐ޸ģ¬ÎÒ×ܽáÁËÒ»ÏÂphpÖÐsessionµÄÓ÷¨¡£
£¨Ò»£©¿ªÊ¼session
¡¡¡¡ÔÚÿһ´ÎʹÓÃsession֮ǰ£¬¶¼Òª¼ÓÉÏÕâÒ»¾ä£º“session_start();”¡£¹ËÃû˼Ò壬Õâ¸öº¯ÊýµÄ×÷ÓþÍÊÇ¿ªÊ¼Ê¹ÓÃsession¡£
£¨¶þ£©×¢ ......
1. PHPµÄCOOKIE
cookie ÊÇÒ»ÖÖÔÚÔ¶³Ìä¯ÀÀÆ÷¶Ë´¢´æÊý¾Ý²¢ÒÔ´ËÀ´¸ú×ÙºÍʶ±ðÓû§µÄ»úÖÆ¡£
PHPÔÚhttpÐÒéµÄÍ·ÐÅÏ¢Àï·¢ËÍcookie, Òò´Ë setcookie() º¯Êý±ØÐëÔÚÆäËüÐÅÏ¢±»Êä³öµ½ä¯ÀÀÆ÷ǰµ÷Óã¬ÕâºÍ¶Ô header() º¯ÊýµÄÏÞÖÆÀàËÆ¡£
1.1 ÉèÖÃcookie:
¿ÉÒÔÓÃ&nbs ......
PHPÊý×麯ÊýÖÐÃ²ËÆÃ»ÓÐÌṩɾ³ýÊý×éÖеÄij¸öÔªËØµÄº¯Êý
µ«È´ÓÐÒ»¸öarray_search£¨²éÕÒÊý×éÖеÄij¸öÔªËØ£¬²¢·µ»ØÆä¼üÃû£©
ÄÇô¾ÍÓÃÒ»ÏÂËüÁË
$array_key = array_search($target_value,$target_array);
if($array_key||$array_key==0)unset($target_array[$target_value]);
//ÕâÀïµÄÌõ¼þÓÃ$array_key!==falseÒ²ÊÇ¿ÉÒԵİ ......