PHP快速入門教程:WHILE迴圈示例

老牛的部落格發表於2006-11-30
<html>                                                           
                                                                 
<head>                                                           
                                                                 
<title>WHILE迴圈示例</title>                      
<meta http-equiv=content-type content=”text/html; charset=gb2312″>
                                                                 
</head>                                                          
                                                                 
<body>                                                           
                                                                 
                                                                 
<h2 align=center >WHILE迴圈示例</h2>                   
                                                                 
<hr color=red>                                                   
                                                                 
<!–PHP程式的開始–>                                             
                                                                 
<?                                                               
                                                                 
echo”<table  align=center width=80% border=1>/n”;                
/******************************                                  
用while迴圈來讀取$GLOBALS陣列的值                                
在迴圈體中顯示出客戶端的資訊                                     
使用了list函式                                                   
*******************************/                                 
while (list($key, $value) = each($GLOBALS))                      
                                                                 
//注意if結構和strlen函式的使用                                   
  { if (strlen($value)<=50)                                      
    {                                                            
    echo “<tr><td>$key</td>”;                                    
    echo “<td>$value</td></tr>/n”;                               
    }                                                            
  }                                                              
                                                                 
echo “</table>/n”;                                               
                                                                 
?>                                                               
                                                                 
<!–PHP程式的結束–>                                             
                                                                 
</body>                                                          
                                                                 
</html>          


相關文章