<?php function demo($a,$b,$c,$d="yellow") { $str ="<table border =2 width =500>"; for($i=0;$i<$a;$i++) { if($i%2==0) { $str .= "<tr bgcolor =$c>"; } else { $str .="<tr bgcolor =$d>"; } for($j=0;$j<$b;$j++) { $str .="<td>".$i."x".$j."=".$i*$j."</td>"; } $str .="</tr>"; } $str .="</table>"; return $str; } $str=demo(10,10,"blue"); echo $str; ?>
2017-07-170个赞
<?php function foo() { echo '我是函数foo哟,调一下我才会执行定义函数bar的过程<br />'; function bar() { echo '在foo函数内部有个函数叫bar的函数<br />'; } } foo(); bar(); bar();bar();bar();bar();bar();bar();bar(); ?> 为什么foo();只能调用一次呢,后面都会报错,什么原因??
2017-07-180个赞
<html> <head></head> <body> <form> <input type = 'text' name = "year"> <input type = 'submit' value = '是否是闰年?'> </form> <?php $year = $_GET['year']; if(!is_numeric($year)||!is_int($year)) { echo "please put Num OR intNum"; return; } if($year%4==0 || !($year%100)) { echo "Is run year"; } else echo "Is't run year"; ?> </body> </html>
2017-06-250个赞
所属章节课程:PHP流程控制之嵌套if...else...elseif结构
<html> <head> <title>判断成绩-test</title> </head> <body> <form> <input type = 'text' name = 'cj'> <input type = 'submit' value ='是否合格?'> </form> <?php $cj = $_GET['cj']; if(!is_numeric($cj)||$cj>100) { echo "请正确输入100分制成绩!"; return; } if($cj<60) { echo "还不及格,必须努力了骚年~~!"; }elseif($cj>60 && $cj<=70) { echo "刚刚及格,还需要努力"; }elseif(70<$cj && $cj<90) { echo "再努力你就是王者"; }elseif ($cj>90) { echo "你现在是王者,但还得努力"; } ?> </body> </html>
2017-06-250个赞
<?php for($i=1; $i<10; $i++) { for($j=1;$j<=$i;$j++) { echo $i.'x'.$j.'='.$i*$j.' '; if ($i==$j) { echo '<br>'; } } } ?>
2017-07-170个赞