html
<!DOCTYPE>
<html>
<meta charset="utf-8">
<head>
<title>九九乘法表</title>
</head>
<body>
<form action="table.php" method="post" >
<input type="text" placeholder="請輸入數字" name="tid"/><br/>
<input type="submit" value="送出"/>
</form>
</body>
</html>
php
<?php
$tid=$_POST['tid'];
$gh;
$fh=fopen('./table.text','a');
for($i=1;$i<=$tid;$i++)
{
for($j=1;$j<=$i;$j++)
{ echo"$i*$j="$i*$j."     ";
fwrite($fh,"$i*$j=".$i*$j." "); }
fwrite($fh,"\n");
echo '<br/>'; }
fclose($fh);
?>
$_post與$_get的差別:
$_get:通過位址欄傳輸
$_post:使用者看不到
*php應該與html中method=""一緻
*php中$_POST['tid']應與name="tid"保持一緻
fopen('./檔案名.txt','a')
fwrite
fclose
r:隻讀(覆寫性)
a:讀(可以接着繼續讀)