<?php header('content-type:text/html;charset=utf-8'); echo <<< 'INPUT' <h3>输入行数和列数,自动生成表格</h3> <form action="" > <label>请输入行数:</label><input type="text" name="tr" placeholder="请输入行数"> <label>请输入列数:</label><input type="text" name="td" placeholder="请输入列数"> <button type="submit" name="submit">生成表格</button> </form> INPUT; $tr=$_GET['tr']; $td=$_GET['td']; echo '<table border="1" cellpadding="3" cellspacing="1">'; for($i=0;$i<$tr;$i++){ echo '<tr>'; for($j=0;$j<$td;$j++){ echo '<td>内容</td>'; } echo '</tr>'; } echo '</table>';