General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old February 10th, 2003, 06:43 PM
arthaus arthaus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Pasadena, CA
Posts: 11 arthaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:
<?php
function bgcolortime() { 
  
$hour date("G"); 
         
  switch(
true) { 
    case(
$hour 12): 
      
$bgcolor "#EEE"
      break; 
    case(
$hour >= 12 && $hour 18): 
      
$bgcolor "#666"
      break; 
    case(
$hour >= 18): 
      
$bgcolor "#333"
      break; 
  }

  return 
$bgcolor

?>

<?php echo bgcolortime(); ?>



I welcome comments/suggestions...

Thankx in advance,
Arthur

Reply With Quote
  #2  
Old February 10th, 2003, 08:05 PM
ramz ramz is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Juiz de Fora - MG- Brazil
Posts: 93 ramz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to ramz Send a message via MSN to ramz
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.

Reply With Quote
  #3  
Old February 10th, 2003, 08:11 PM
arthaus arthaus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Pasadena, CA
Posts: 11 arthaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old February 10th, 2003, 08:55 PM
ramz ramz is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Juiz de Fora - MG- Brazil
Posts: 93 ramz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to ramz Send a message via MSN to ramz
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... =)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > BG Color & Time --> Please critique my code...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway