開発環境
- OS X Lion - Apple(OS)
- Apache (Web Server)
- PHP (サーバーサイドプログラミング言語)
- MySQL (データベース)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
『初めてのPHP & MySQL 第2版』(Michele E. Davis、Jon A. Phillips 著、西沢 直木 訳、オライリー・ジャパン、2008年、ISBN978-4-87311-365-4)の5章(関数)の問題を解いてみる。
問5-1.
間違いを修正したのを下記のコードに。
問5-2, 3
下記のコードに。
問5-4.
ファイルが存在しない場合、include()の場合はそのまま処理が続けられるけど、require()の場合はエラーで処理が中断される。
問5-5.
クラスの一部として実行された関数は、メソッドと呼ばれている。
コード(TextWrangler)
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<title></title>
</head>
<body>
<?php
function Response(){
echo "Have a good day!<br /><br />";
}
echo "Are you going to merge? <br />";
Response();
echo "I need a status report on all your projects in the next 10 minutes for
my management meeting.<br />";
Response();
echo "Did Bill get everything he needed today? He was sure crabby!<br />";
Response();
?>
<?php
function toast($m){
echo "done.<br />";
}
toast(5);
?>
</body>
</html>
出力結果(ブラウザ)
Are you going to merge? Have a good day! I need a status report on all your projects in the next 10 minutes for my management meeting. Have a good day! Did Bill get everything he needed today? He was sure crabby! Have a good day! done.
HTMLソース
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<title></title>
</head>
<body>
Are you going to merge? <br />Have a good day!<br /><br />I need a status report on all your projects in the next 10 minutes for
my management meeting.<br />Have a good day!<br /><br />Did Bill get everything he needed today? He was sure crabby!<br />Have a good day!<br /><br /> done.<br /> </body>
</html>
併せて読んでいる書籍。
Pythonの学習が1周したら上記の2冊を順に取り組む計画。それまではひたすら復習!
0 コメント:
コメントを投稿