<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <table border="1" width="800" height="400"> <?php for ($i = 1; $i <= 9; $i++) { echo '<tr>'; for ($k = 1; $k <= $i; $k++) { $s = $k * $i; echo "<td style='text-align: center'>$k * $i = $s</td>"; } echo '</tr>'; } ?> </table> </body> </html>
demo 效果: