PHP復習
◆PHP復習
【フォームを取得】
《input.php》
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>フォーム情報を取得する</title> </head> <body> <form method="post" action="output.php"> お名前: <input type="text" name="name" size="20" maxlength="30"> <input type="submit" value="送信"> </form> </body> </html>
《output.php》
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>フォームを取得する</title> </head> <body> <form> こんにちは、<?php print(htmlspecialchars($_POST['name'],ENT_QUOTES,'UTF-8')); ?>さん! </form> </body> </html>
情報を取得する際の、
<?php print(htmlspecialchars($_POST['name'], ENT_QUOTES, 'UTF-8')); ?>
絶対忘れないこと!!
<?php print("2012年2月のカレンダー<br>"); for($i = 1; $i < 32; $i++){ if(checkdate(2,$i,2012)){print("{$i} ");} } ?>
※if(checkdate(2,$i,2012)){print("{$i} ");} の「 」は横並びの際の全角空白
【Datepicker(jQuery UI)】※PHPではない
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>jQuery UI Example Page:datepicker</title> <link type="text/css" href="css/sunny/jquery-ui-1.8.17.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script> <script type="text/javascript"> $(function(){ //Datepicker $('#datepicker').datepicker({ inline: true }) }); </script> <style type="text/css"> #datepicker{ font-size: 62.5%; font-family: "Trebuchet MS",sans-serif; margin: 50px; } </style> </head> <body> <!--Datepicker--> <div id="datepicker"></div> </body> </html>
下記スクリプトはbody内の「<div id="datepicker"></div>」のdivタグの間に読み込まれる。
<script type="text/javascript"> $(function(){ //Datepicker $('#datepicker').datepicker({ inline: true }); }); </script>
★jQuery UIのThemeRollerでDatepickerを設定、ダウンロード
- http://jqueryui.com/themeroller/ の『Gallery』で好きな色を選択する。
- 右側に反映されたのを確認し、『Roll Your Own』 にもどる。
- 『Download Theme』をクリック。
- 『Build Your Download』のページへ移動。必要な項目にチェックを入れ、そのまま右側の『Download』でダウンロード。(CoreとDatepickerにチェック)
- zipフォルダを展開し、必要なフォルダおよびファイルを作成中のフォルダに移動する。
- Datepickerはすでにヴィジェットとして実用的に使うことができるサイズになっているが、文字が大きくなればそれにあわせて自動的にサイズ変更する。
→ スタイルシート font-size: 62.5%; で指定されているため。
※Datepickerのようなカレンダーは基本的に日付を確認するといった使い方をする。カレンダー内に書き込む場合は、googleカレンダーを設置すること。
【メモ】
サイト内に検索されたくないページがある場合は、下記を記述したテキスト(robots.txt)を作成し、index.htmlと同階層に保存する。
User-agent:*
Disallow:/〜〜/〜〜〜 ← 〜〜は検索されたくないページの絶対パス
Disallow:/〜〜/〜〜〜
※URLの末尾に『/』をつけた場合は、このサイト全体が検索されなくなるので注意。