php »ù´¡±Ê¼Ç logic statements
/***************************by
garcon1986********************************/
<?php
//if Óï¾ä
$a = $b = 3;
if($a = $b)
print "a is equal to b<br>";
//else Óï¾ä
if($a < $b){
print "a is smaller than b";
} else {
print "a is not smaller than b<br>";
}
//elseif = else if Óï¾ä
if($a>$b){
print "a is bigger than b";
}else if($a = $b){
print "a is equal than b";
}else {
print "a is smaller to b<br>";
}
// when you don't use "{}", you can't separate elseif.
//µ±²»ÓÃ{}ʱ£¬elseif²»ÄÜ·Ö¿ª
if($a>$b):
print "a>b";
elseif($a==$b):
//else if($a==$b): // this is wrong
print "a=b";
print '<br>';
endif;
//whileÓï¾ä
$i = 0;
while($i<=10){
print $i++.'<br>';
}
$i=15;
while($i<=20):
print $i;
$i++;
endwhile;
print '<br>';
//The difference between 'do while' and 'while' is: 'do while' will execute once at least.
//do while ºÍwhileµÄÇø±ðÔÚÓÚÇ°ÕßÖÁÉÙÒªÖ´ÐÐÒ»´Î
$i=0;
do {
echo $i;
}while($i>0);
echo '<p>';
//do while example 2
do {
if ($i < 5) {
echo "i is not big enough";
break;
}
$i *= 2;
if ($i < 50) {
break;
}
echo "i is ok";
/* process i */
} while (0);
//for(expression1; expression2; expression3) statementÓï¾ä
//example1
for($i=0;$i<=6;$i++){
print $i;
}
echo '<br>';
//example2
for($i=0; ; $i++){
if($i>10){
break;
}
print $i;
}
echo '<br>';
//example3
for($i=0;;){
print $i;
$i++;
if($i>6){
break;
}
}
echo '<br>';
//example4
$i=0;
for(;;){
if($i>6){
break;
}
print $i;
$i++;
}
echo '<br>';
//example5
for($i=0;$i<=10;print $i, $i++);
echo '<p>';
//foreachÓï¾ä
//example1
$arr = array('s','j','g','w','l');
foreach($arr as $value){
echo "$value<br>"; //$value is user-defined.
}
unset($value);
//list to replace foreach, same result
//ʹ
Ïà¹ØÎĵµ£º
5.¹ØÓÚ±íµ¥Ë¢ÐÂ
ÎÊ£ºÎªÊ²Ã´ÎÒÔÚµã»÷ä¯ÀÀÆ÷µÄºóÍË°´Å¥ºó£¬ËùÓÐ×ֶεÄÐÅÏ¢¶¼±»Çå¿ÕÁË£¿
´ð£ºÕâÊÇÓÉÓÚÄãÔÚÄãµÄ±íµ¥Ìá½»Ò³ÃæÖÐʹÓÃÁË session_start º¯Êý¡£¸Ãº¯Êý»áÇ¿ÖƵ±Ç°Ò³Ãæ²»±»»º´æ¡£½â¾ö°ì·¨Îª£¬ÔÚÄãµÄ Session_start º¯Êýºó¼ÓÈë header("Cache-control: private"); ×¢ÒâÔÚ±¾ÐÐ֮ǰÄãµÄPHP³ÌÐò²»ÄÜÓÐÈκÎÊä³ö¡£
²¹³ä£º ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>PHP·ÖÒ³</tit ......
¡¶Head First
Éè¼Æģʽ¡·ÊDZ¾²»´íµÄ½²½âÉè¼ÆģʽµÄÊ飬²»ÏñF4дµÄÄÇô¿ÝÔӦ¸ÃËãÊDZȽÏÈÝÒ×Àí½âµÄºÃÊé¡£ÊéÖеÄÀý×Ó¶¼±È½ÏdzÏÔÒ׶®£¬²»¹ýÓÉÓÚÊÇÍâ¹úÀÐдµÄ£¬ËùÒÔÀý×Ó
µÄÏ°¹ß²»ÊǺܸ½ºÏÖйúÌØÉ«£¬¿ÉÄÜż¶û¿´ÆðÀ´ÓÐЩ±ðŤ£¬»¹ÓÐÓïÑÔÏ°¹ßÒ²²»ÊÇÖйú·ç¡£µ±È»¿´¹ýÕâ±¾ÊéÖ®ºó£¬Äã²ÅÄÜÉî¿ÌÀí½âÉè¼Æģʽµ½µ×ÄÜΪÄã½â¾öÄÄЩ
퉣 ......
Nginx + PHP + Mysql (php-frm 방식)
글쓴이 :
최고관리자
조회 : 2,884
......