PHP是老师经常会要我们做这个的题目,今天我再做一次打印乘法口决,PHP代码如下:
<?php /* *打印乘法口绝表 */ echo "九灵九乘法口绝表<br><br><br>"; echo "<table>"; for ($i = 1; $i <= 9; $i++) { echo "<tr>"; for ($j = 1; $j <= $i; $j++) { echo "<td>" . $j . "*" . $i . "=" . ($j * $i) . "</td>"; } echo "</tr>"; } echo "</table>"; echo "<br><br><br><br><br><br>"; echo "<table>"; for ($i = 1; $i <= 9; $i++) { echo "<tr>"; for ($j = $i; $j <= 9; $j++) { echo "<td>" . $i . "*" . $j . "=" . ($j * $i) . "</td>"; } echo "</tr>"; } echo "</table>"; ?>
一个简单的求和
<?php function sum($n) { if ($n > 1) { return sum($n - 1) + $n; } else { return 1; } } echo sum(100); ?>
文章网址:
随意转载^^但请附上教程地址。