2006/8/29 学籍番号 名前 |
問題1 $aはいくつになるか?
$a=100;
if(($a-1)<100) $a=$a+100;
else $a=$a+1000;
問題2 $xはいくつになるか?
$x=0;
for($a=1; $a<=10; $a++){
$x=$x+$a;
}
問題3 間違いが4箇所ある。間違えている個所に二重線を引き、適切に訂正せよ。
(全てのファイルは同じフォルダに入っている。)
omise1.php | <html> <head> <title>お店に入場</title> </head> <body> <p>お店に入場</p> <form name="f1" method="post" action="post"> お名前:<input type="text" name="username" value=" <?php if(isset($_COOKIE['username'])) print username; ?> "> <input type="submit" name="sub" value="入場"> </form> </body> </html> |
omise2.php | <?php if($_POST["username"] = "") exit("お名前を入力ください"); ?> <html> <head> <title>お店に入場</title> </head> <body> <p><?php print $_POST["username"]; ?> さん</p> <p>ようこそお店へ</p> <?php setcookie("username", $_POST["username"], time()+60*60*24*60); ?> </body> </html> |
問題4 上記クッキーに、名前が保存されている期間は何日間か?
問題5 3つの値の合計値を返す(return) 関数(function)がある。
その関数を呼び、結果をプリントする スクリプトは次のように記述する。
$g=gokei(51, 55, 1);
print $g;
どのような関数か書いてみよ。