開発環境
- OS X Lion - Apple(OS)
- Apache (Web Server)
- PHP (サーバーサイドプログラミング言語)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
『初めてのPHP5』 (David Sklar 著、 桑村 潤 翻訳、 廣川 類 翻訳、 オライリー・ジャパン、2005年、ISBN978-4-87311-257-2)の5章(関数)5.6(演習問題)4を解いてみる。
4.
コード(TextWrangler)
<?php function f($red, $green, $blue){ $color = array($red,$green,$blue); $result = "#"; for($i = 0 ; $i < count($color); $i++){ $result .= sprintf("%02s",dechex($color[$i])); } return $result; } $color = f(255,0,255); print "<body style=\"background:$color;\"></body>"; ?>
HTMLソース
<body style="background:#ff00ff;"></body>
0 コメント:
コメントを投稿