标签:表示 header block rand har cte pen image pre
<?php function table($row,$col,$c){ $str= "<table border=1>"; for ($i=0; $i <$row ; $i++) { //$i表示行 0~9 $color=$i % 2==0?"#ffffff":$c;//三元运算符 $i % 2==0为true 执行$color="#fff" 否则 执行 $color="#ccc"; $str=$str. "<tr bgcolor=$color>"; for ($j=0; $j <$col ; $j++) { //$j:0~9 $str=$str. "<td>".($j+$i*$col)."</td>"; } $str=$str. "</tr>"; } $str=$str. "</table>"; return $str; } echo table(10,10,"red"); echo "<br>"; echo table(5,5,"green"); header("content-type:html/text;charset=utf-8"); function genPassword($min = 5, $max = 8) { $validchars="abcdefghijklmnopqrstuvwxyz1234567890"; $max_char=strlen($validchars)-1; $length=mt_rand($min,$max); $password = ""; for($i=0;$i<$length;$i++ ) { $password.=$validchars[mt_rand(0,$max_char)]; } return $password; } echo "生成的密码:".genPassword(5,5)."<br>"; ?>
随机密码,表格
标签:表示 header block rand har cte pen image pre
原文地址:http://www.cnblogs.com/tcheng/p/6140612.html