PHPÊý×éµÄʹÓúͱéÀú
1¡¢Êý×éµÄÉêÇëºÍʹÓãº
$array=array(array(2,324,34));
echo $array[0][1];
Ö±½ÓÉêÇëʹÓãº
$student[0][0]="ÎÒ";
$student[0][1]="ÊÇ";
$student[1][0]="Ë";
$student[1][1]="ά";
echo $student[1][0];
2¡¢±éÀú£º
foreach()ÊÇÒ»¸öÓÃÀ´±éÀúÊý×éÖÐÊý¾ÝµÄ×î¼òµ¥ÓÐЧµÄ·½·¨¡£
<?php
$colors = array('red','blue','green','yellow');
foreach ($colors as $color) {
echo "Do you like $color? <br />";
}
?>
ÏÔʾ½á¹û£º
Do you like red?
Do you like blue?
Do you like green?
Do you like yellow?
2. while()
while() ͨ³£ºÍ list()£¬each()ÅäºÏʹÓá£
#example2:
<?php
$colors = array('red','blue','green','yellow');
while(list($key,$val) = each($colors)) {
echo "Other list of $val.<br />";
}
?>
ÏÔʾ½á¹û£º
Other list of red.
Other list of blue.
Other list of green.
Other list of yellow.
3. for()
#example3:
<?php
$arr = array ("0" => "zero","1" => "one","2" => "two");
for ($i = 0;$i < count($arr); $i++) {
$str = $arr[$i];
echo "the number is $str.<br />";
}
?>
ÏÔʾ½á¹û£º
the number is zero.
the number is one.
the number is two.
========= ÒÔÏÂÊǺ¯Êý½éÉÜ ==========
key()
mixed key(array input_array)
key()º¯Êý·µ»Øinput_arrayÖÐλÓÚµ±Ç°Ö¸ÕëλÖõļüÔªËØ¡£
#example4
ÏÂÔØ: list_array04.php
<?php
$capitals = array("Ohio" => "Columbus","Towa" => "Des Moines","Arizona" => "Phoenix");
echo "<p>Can you name the capitals of these states?</p>";
while($key = key($capitals)) {
echo $key."<br />";
next($capitals);
//ÿ¸ökey()µ÷Óò»»áÍÆ½øÖ¸Õ롣Ϊ´ËҪʹÓÃnext()º¯Êý
}
?>
ÏÔʾ½á¹û£º
Can you name the capitals of these
Ïà¹ØÎĵµ£º
˵Ã÷£ºÒòΪ×î½ü¹¤×÷¹¤×÷¹ØÏµ£¬ÐèÒª¿ª·¢Ò»¸öÔÚLinuxÏÂÔËÐеÄWeb Application£¬ÐèÒª¶ÔÏÖÔڱȽÏÁ÷ÐеÄһЩPHP¿ò¼Ü×öÒ»¸öÁ˽âºÍÆÀ¹À£¬ÏÂÃæµÄÕâÆªÎÄÕÂÊDZÊÕß×î½üѧϰһ¸ö±È½ÏеÄPHP FrameworkµÄÒ»µã¾ÀúºÍ²Ù×÷²½Ö裬ÒòΪ¹Ù·½µÄÊÖ²áдµÃ±È½Ï»Þɬ£¨ÌرðÊÇÖÐÎĵģ©£¬Ôø¾³¢ÊÔ±é¶ÁËüÄǸöÊÖ²áÔÙ¶¯ÊÖ£¬¶ÁÁËÒ»´ó°ë·¢ÏÖÈÔÎÞ·¨Àí½â£¬ÓÚÊÇ ......
<?php
/*ʹÓÃÎı¾Îļþ¼Ç¼Êý¾ÝµÄ¼òµ¥ÊµÏÖ*/
$counter=1;
if(file_exists("mycounter.txt")){
$fp=fopen("mycounter.txt","r");
$counter=fgets($fp,9);
$counter++;
fclose($fp);
}
$fp=fopen("mycounter.txt","w");
fputs($fp,$counter);
fclose($fp);
echo "<h1>ÄúÊǵÚ".$counter."´Î·ÃÎʱ¾Ò³ ......
±¾½Ì³Ì²ÉÓõÄÊÇxampp×Ô´øµÄtomcat²å¼þÀ´Íê³ÉÕûºÏµÄ£¬ËùÒÔ£¬ÒªÏëÍê³ÉÕûºÏ£¬µÚÒ»²½²»ÐèÏÂÔØxampp£¬¼°Æätomcat²å¼þ~
1.´ò¿ªxampp¹ÙÍø µã´Ëxampp¹ÙÍø´ò¿ª
&n ......
//´´½¨Îļþ¼ÐµÄ·½·¨
//$path ΪÎļþ¼Ð²ÎÊý£¬Èç £¨c:/program files/makedir£©
function createFolders($path) {
if (!file_exists($path)) {
$this->createFolders(dirname($path));
mkdir($path, 0777);
&n ......
ÎÒ·¢ÏֺܶàµÄPHP³ÌÐòÔ±£¬ÓÈÆäÊÇѧϰ»¹²»ÊǺܾõ쬶¼²»ÖªµÀPHPµÄ¾«»ªËùÔÚ¡£Perlµ±ÄêÈçºÎÔÚÉ̽ç³öÃû£¿ÆäÇ¿´óµÄÕýÔò±í´ïʽ¡£¶øPHPÄØ£¿ËûÊÇÒ»ÃÅ´ÓUnixÏ·¢Õ¹ÆðÀ´µÄÓïÑÔ£¬µ±È»Ò²¾Í¼Ì³ÐÁËPerlµÄºÜ¶àÌØµã£¬Í¬Ê±CµÄÓŵ㶼ÓС£¿ìËÙ¡¢¼ò½à¡¢Ã÷ÁË£¬ÓÈÆäÊÇC³ÌÐòÔ±£¬PHPÊÇÖÁ°®£¬ÎÒ¾ÍÊÇÉî°®×Å“PHP”£¨¶¼ÍüÁËÅ®ÓÑÁË:)£©¡ ......