2012年5月20日日曜日

開発環境

『初めてのPHP5』 (David Sklar 著、 桑村 潤 翻訳、 廣川 類 翻訳、 オライリー・ジャパン、2005年、ISBN978-4-87311-257-2)の5章(関数)5.6(演習問題)4を解いてみる。

4.

コード(TextWrangler)

sample19.php

<?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 コメント:

コメントを投稿