|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
BG Color & Time --> Please critique my code...
Hi all,
I have the following code (modified it from normal page greeting) that changes background color of a page depending time of a day. Q: Is my code efficient? PHP Code:
I welcome comments/suggestions... Thankx in advance, Arthur |
|
#2
|
|||
|
|||
|
Hi Arthur!
Well... efficient it is... but try add something more, like this: function bgcolor() { $hour = date("G"); if($hour <= 12) { switch($hour) { case 8: $color = "#FFFFFF"; break; case 10: $color = "#F0F0F0"; break; case 12: $color = "#FFFFCC"; break; default: $color = "#CC66FF"; break; } } elseif(($hour > 12) && ($hour <= 18)) { switch($hour) { case 14: $color = "#FFFF00"; break; case 16: $color = "#FF0000"; break; case 18: $color = "#0000FF"; break; default: $color = "#FFCC00"; break; } } else { switch($hour) { case 20: $color = "#FFFFFF"; break; case 22: $color = "#F0F0F0"; break; case 23: $color = "#FFFFCC"; break; default: $color = "#CC66FF"; break; } } return $color; } I think that this improvement in the function, gives to you more resources to have more alternative colors... what do you think?
__________________
Regards, Ramiro Varandas Jr. Last edited by ramz : February 10th, 2003 at 08:08 PM. |
|
#3
|
|||
|
|||
|
Hi Ramiro,
I like your suggestions. I'm just wondering if it's too much to have so many color changes. I may use your method with grayscale colors (from light to darkness). I appreciate your input, Arthur |
|
#4
|
|||
|
|||
|
Ok... no problem...
It's what I've told you, your code is perfect and works fine, the other one I've typed just gives you more variety of colors... =) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > BG Color & Time --> Please critique my code... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|