phpѧϰÊղأºPHPÊý×éµÄ×ܽá
Ò»¡¢Ê²Ã´ÊÇÊý×é
Êý×é¾ÍÊÇÒ»×éÊý¾ÝµÄ¼¯ºÏ£¬°ÑһϵÁÐÊý¾Ý×éÖ¯ÆðÀ´£¬ÐγÉÒ»¸ö¿É²Ù×÷µÄÕûÌå¡£Êý×éµÄÿ¸öʵÌ嶼°üº¬Á½Ï¼üºÍÖµ¡£
¶þ¡¢ÉùÃ÷Êý¾Ý
ÔÚPHPÖÐÉùÃ÷Êý×éµÄ·½Ê½Ö÷ÒªÓÐÁ½ÖÖ£ºÒ»ÊÇÓ¦ÓÃarray()º¯ÊýÉùÃ÷Êý×飬һÊÇÖ±½ÓΪÊý×éÔªËظ³Öµ¡£
<1>array()º¯ÊýÉùÃ÷µÄÊý×éµÄ·½Ê½array([mixed...]) ²ÎÊýmixedµÄÓ﷨Ϊkey=>value
È磬<?php
$array=array("1"=>"±à","2"=>"³Ì","3"=>"´Ê","4"=>"µä");
print_r($array);
echo "<br>";
echo $array[1]; //×¢Ò⣺ϱêĬÈÏÊÇ´Ó0¿ªÊ¼
echo $array[2];
echo $array[3];
echo $array[4];
?>
<2>Ö±½ÓΪÊý×éÔªËظ³Öµ¡£Èç¹ûÔÚ´´½¨Êý×éʱ²»ÖªËù´´½¨Êý×éµÄ´óС£¬»òÔÚʵ¼Ê±àд³ÌÐòʱÊý×éµÄ´óС¿ÉÄÜ·¢Éú±ä»¯£¬²ÉÓÃÕâÖÖÊý×é´´½¨µÄ·½·¨½ÏºÃ¡£
È磬<?php
$array[1]="I";
$array[2]="love";
$array[3]="PHP";
print_r($array); //Êä³öËù´´½¨Êý×éµÄ½á¹¹
?>
Èý¡¢Êý×éµÄÀàÐÍ
PHPÖ§³ÖÁ½ÖÖÊý×飺Ë÷ÒýÊý×é(indexed array)ºÍÁªºÏÊý×é(associative array)£¬Ç°ÕßʹÓÃÊý×Ö×÷Ϊ¼ü£¬ºóÕßʹÓÃ×Ö·û´®×÷Ϊ¼ü¡£
ËÄ¡¢Êä³öÊý×é
ÔÚPHPÖжÔÊý×éÔªËØÊä³ö£¬¿ÉÒÔͨ¹ýechoºÍprintÓï¾äÀ´ÊµÏÖ£¬µ«ÕâÖ»ÄܶÔÊý×éÖÐijһԪËؽøÐÐÊä³ö£»Òª½«Êý×é½á¹¹Êä³öÔòҪʹÓÃprint_r()º¯Êý£¬ÆäÓï·¨£ºprint_r(mixed expression),²ÎÊýexpressionΪÆÕͨµÄÕûÐΡ¢×Ö·ûÐÍ»òʵÐͱäÁ¿ÔòÊä³ö¸Ã±äÁ¿±¾Éí£¬Èç¹û¸Ã²ÎÊýΪÊý×飬Ôò°´Ò»¶¨¼üÖµºÍÔªËصÄ˳ÐòÏÔʾ³ö¸ÃÊý×éÖеÄËùÓÐÔªËØ¡£
Îå¡¢Êý×éµÄ¹¹Ôì
һάÊý×飺
µ±Ò»¸öÊý×éµÄÔªËØÊDZäÁ¿Ê±£¬Ôò³ÆÆäΪһάÊý×é¡£
ÉùÃ÷һλÊý×飺 ÀàÐÍ˵Ã÷·û Êý×éÃû[³£Á¿±í´ïʽ]£»
¶þάÊý×飺
µ±Ò»¸öÊý×éµÄÔªËØÊÇÒ»¸öһλÊý×éʱ£¬Ôò³Æ֮Ϊ¶þάÊý×é¡£
È磬<?php
$str = array (
"ÍøÂç±à³ÌÓïÑÔ"=>array ("PHP","JSP","ASP"),
"ÌåÓýÏîÄ¿"=>array ("m"=>"×ãÇò","n"=>"ÀºÇò"));
print_r ( $str) ;
?>
Áù¡¢±éÀúÊý×é
±éÀúÊý×éÖеÄËùÓÐÔªËØÊdz£ÓõÄÒ»ÖÖ²Ù×÷£¬ÔÚ±éÀúµÄ¹ý³ÌÖпÉÒÔÍê³É²éѯ»òÆäËû¹¦ÄÜ¡£ÔÚPHPÖбéÀúÊý×éµÄ·½·¨ÓжàÖÖ£¬ÏÂÃæ½éÉÜ×î³£ÓõÄÁ½ÖÖ·½·¨¡£
<1>ʹÓÃforeach½á¹¹±éÀúÊý×飻
<2>ʹÓÃlist()º¯Êý±éÀúÊý×飬list()º¯Êý½öÄÜÓ
Ïà¹ØÎĵµ£º
½ñÌì¿´µ½ÁËÒ»±Ê¼ÇÉÏÃæÊÇÕâô˵µÄ£º
2. ²»×ªÒâSQLÊäÈë
ÎÒÔø¾ÔÚһƪÎÄÕÂÖÐ×î¼òµ¥µÄ·ÀÖ¹sql×¢ÈëµÄ·½·¨(php+mysqlÖÐ)ÌÖÂÛ¹ýÕâ¸öÎÊÌâ²¢¸ø³öÁËÒ»¸ö¼òµ¥µÄ·½·¨ ¡£ÓÐÈ˶ÔÎÒ˵£¬ËûÃÇÒѾÔÚphp.iniÖн«magic_quotesÉèÖÃΪOn£¬ËùÒÔ²»±Øµ£ÐÄÕâ¸öÎÊÌ⣬µ«ÊDz»ÊÇËùÓеÄÊäÈ붼ÊÇ´Ó$_GET, $_POST»ò $_COOKIEÖеĵõ½µÄ£¡
ÈçºÎÐÞ¸´£º
ºÍ ......
¶Ô±ÈÆð Cookie£¬Session ÊÇ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ»á»°£¬Ïà¶Ô°²È«£¬²¢ÇÒ²»Ïñ Cookie ÄÇÑùÓд洢³¤¶ÈÏÞÖÆ£¬±¾Îļòµ¥½éÉÜ Session µÄʹÓá£
ÓÉÓÚ Session ÊÇÒÔÎı¾ÎļþÐÎʽ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ£¬ËùÒÔ²»Å¿ͻ§¶ËÐÞ¸Ä Session ÄÚÈÝ¡£Êµ¼ÊÉÏÔÚ·þÎñÆ÷¶ËµÄ Session Îļþ£¬PHP ×Ô¶¯ÐÞ¸Ä Session ÎļþµÄȨÏÞ£¬Ö»±£ÁôÁËϵͳ¶ÁºÍдȨÏÞ£¬¶ø ......
ʲôÊÇSESSION£¿ °´ÕÕWIKIµÄ½âÊÍ£¬SESSIONÊÇ´æÔÚÓÚÁ½¸öͨÐÅÉ豸¼äµÄ½»»¥ÐÅÏ¢£¬ÔÚijһʱ¼ä½¨Á¢£¬¾¹ýÒ»¶¨µÄʱ¼äºóʧЧ¡£³£¼ûµÄSESSIONÓУºTCP SESSION¡¢WEB SESSION£¨HTTP SESSION£©¡¢LOGIN SESSIONµÈ¡£ ¸ù¾ÝOSIÄ£ÐÍÖУ¬»á»°ÊµÏÖµÄλÖò»Í¬£¬SESSIONÖ÷Òª·ÖΪ¼¸ÖÖ£¬Ò»ÖÖÊÇÓ¦Óòã»á»°£¬°üÀ¨WEB SESSION£¨HTTP SESSION£©ºÍtel ......
ÆÕͨË÷Òý ¹Ø×¢Õâ¸öÁРΨһË÷Òý Ö÷¼ü ¶àÁÐË÷Òý ¹Ø×¢¶à¸öÁÐ Àý£º¶àÁÐË÷Òý F1 F2 F3 µ¥²éF2»òF3Ë÷ÒýÎÞЧ Ë÷ÒýÊÇΪÁ˼ӿì¼ìË÷ Êý¾Ý¿â µÚÒ»·¶Ê½£º Ò»¸ö±íÖеÄÁÐÓ¦¸ÃÊDz»¿ÉÔٷֵģ¬È·±£ÁеÄÔ×ÓÐÔ µÚ¶þ·¶Ê½£º Ö»ÓÐÖ÷¼ü²ÅÄܱíÏÖÊý¾ÝÌØÕ÷£¬¶ø·ÇÖ÷¼üÁл¥²»¸ÉÉ棬ȷ±£Ê ......
Ç°ÑÔ£º
¡¡¡¡FCKeidtorÊǸö¹úÍâµÄ¶àÓïÑÔ±à¼Æ÷£¬Äã¿ÉÒÔ¶ÔÆäÅäÖÃÎļþ½øÐмòµ¥ÐÞ¸Äʹ֧֮³ÖÄ¿Ç°³£ÓÃWeb¿ª·¢ÓïÑÔµÄÓ¦Óã¬ÏÂÃæÎҾͽ²½²FCKeditorµÄ×îа汾2.4.2ÔÚphpµÄ¾ßÌåÅäÖùý³Ì£¬Óв»×ãºÍ³ö´íµÄµØ·½£¬»¶ÓÖ¸Õý¡£
¾«¼ò£º
¡¡¡¡ÕýÒòΪÕâ¸ö±à¼Æ÷ÊÇÖ§³Ö¶àÓïÑԵģ¬ËùÒÔÊ×ÏÈÎÒÃÇÕë¶ÔʹÓöÔÆä×öÏàÓ¦µÄÈßÓàÎļþɾ³ý¡£
¡¡¡ ......