After following, you can keep track of his dynamic information in a timely manner
Courses in the relevant section:PHP function basic syntax custom function
<?php echo '<table widch="800">'; function demo($cor=10,$row=10,$color1,$color="pink"){ for($x=0;$x<$row;$x++){ if($x%2==0){ echo "<tr bgcolor='$color'>"; }else{ echo"<tr bgcolor='$color1'>"; } for($y=0;$y<$cor;$y++){ echo "<td>".($row*$x+$y)."</td>"; } echo "</tr>" ; } } demo(40,35,'yellow'); ?>
2017-06-090個贊
Courses in the relevant section:php ?foreach traverses associative arrays
<?php $arr=array( '教學部'=>array( array('李某','18','人妖'), array('高某','20','男'), array('張某','21','妖人'), ), '宣傳部'=>array( array('李某','18','人妖'), array('高某','20','男'), array('張某','21','妖人'), ), '財務部'=>array( array('李某','18','人妖'), array('高某','20','男'), array('張某','21','妖人'), ), ); foreach($arr as $xia1=>$yuansu1){ foreach($yuansu1 as $xia2=>$yuansu2){ echo $xia1; foreach($yuansu2 as $xia3=>$yuansu3){ echo '-'.$yuansu3; } echo '<br />'; } echo '-------------------'.'<br />'; } ?>
2017-06-120個贊
Courses in the relevant section:PHP list, each function traverses the array
抄的 <?php $arr=array( '教學部'=>array( array('李某','18','人妖'), array('高某','20','男'), array('張某','21','妖人'), ), '宣傳部'=>array( array('李某','18','人妖'), array('高某','20','男'), array('張某','21','妖人'), ), '財務部'=>array( array('李某','18','人妖'), array('高某','20','男'), array('張某','21','妖人'), ), ); while(list($k1,$v1)=each($arr)){//下標為教學部,元素為數(shù)組 echo '<h1 style="text-align:center;">'.$k1.'</h1>';//第一層教學部 文本居中text-align:center echo '<table style="width:100%;">';//width:100% 不管瀏覽器大小,寬度都充滿整個瀏覽器 while(list($k2,$v2)=each($v1)){//each第一層元素,拆解出第二層下標和元素 ,都無用 echo '<tr>';//第三層的換行 while(list($k3,$v3)=each($v2)){//each第二層元素,拆解出第三層下標(無用)和元素(輸出) echo '<td style="border:2px solid #999;">'.$v3.'</td>';//輸出元素3 定義表格邊框寬度顏色 } echo '</tr>'; } echo '</table>'; } ?>
2017-06-120個贊
Courses in the relevant section:PHP flow control if statement
<form> <input type="text" name="num"> <input type="submit" value="輸入年份" /> </form> <?php /*閏年平年計算器*/ @ $num=$_GET['num']; //加@,不然第一次報錯 if(is_null($num)){ echo "請輸入年份"; }else{ //var_dump($num); $num1=(int)$num; if(is_int($num1)&& $num1!= null){ if($num%4==0){ echo $num1."年是閏年"; }else{ echo $num1."年是平年"; } }else{ echo "輸入的年份不對!"; } } ?>
2017-06-070個贊
Courses in the relevant section:Nested if...else...elseif structure of PHP process control
<?php include('cj.html'); $grade=$_POST['grad']; settype($grade,'float'); if($grade>0 && $grade<60){ echo "分數(shù)為".$grade."。不及格!"; }else{ if($grade>=60 && $grade<70){ echo "分數(shù)為".$grade."。要努力!"; }else{ if($grade>=70 && $grade<80){ echo "分數(shù)為".$grade."。還不錯!"; }else{ if($grade>=80 && $grade<90){ echo "分數(shù)為".$grade."。上清華!"; }else{ if($grade>=90 && $grade<100){ echo "分數(shù)為".$grade."。強無敵!"; }else{ if($grade==100){ echo "分數(shù)為".$grade."。不可能!"; }else{ if($grade>100){ echo "分數(shù)為".$grade."。大神?。?!"; }else{ echo "請輸入正確的分數(shù)!"; } } } } } } } ?>
<html> <head> <title>成績判斷</title> </head> <body> <h3>成績分段</h3> <form action="panduan.php" method="post"> <input type="text" name="grad"/> <input type="submit" value="提交"/> </form> </body> </html>
2017-06-090個贊
Courses in the relevant section:PHP flow control for loop control statement
<?php echo '<table widch="800" border="1">'; for($i = 1 ; $i < 10 ; $i++ ){ if($i%2==0){ echo '<tr bgcolor="pink">'; } /*if($i==4){ continue; } if($i==8){ break; }*/ for($j=1;$j<=$i;$j++){ echo '<td>'.$j . 'x' . $i . '=' .($i*$j) . ' '.'</td>'; } echo '<tr>'; } echo '</table>' ?>
2017-06-090個贊