RE: Switch statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It looks like you can do something like the following (I have NOT
tried it; reference the _comments_ in [1]):

<?php

switch ($hour) {
case ($hour <= 7 OR $hour > 23):
	echo "Go to sleep you night owl!";
	break;
case ($hour >= 7 AND $hour <= 12):
	echo "Good morning, Sunshine!";
	break;
case ($hour == 12):
	echo "Lunchtime!";
	break;
case ($hour >= 22 AND $hour <= 23):
	echo "Good night.";
	break;
}

?>


[1]http://www.php.net/manual/en/control-structures.switch.php

- --
- - Charlie
 
5A27 58D2 C791 8769 D4A4  F316 7BF8 D1F6 4829 EDCF
 
 In memoriam:  http://www.militarycity.com/valor/1029976.html


 

> -----Original Message-----
> From: fedora-list-bounces@xxxxxxxxxx 
> [mailto:fedora-list-bounces@xxxxxxxxxx] On Behalf Of Dotan Cohen
> Sent: Monday, December 12, 2005 9:47 AM
> To: For users of Fedora Core releases
> Subject: Switch statement
> 
> I have no problem using the switch statement when I am checking if
> a variable equals a known number, like such:
> 
> <?php
> switch ($hour) {
> case 0:
>    echo "Go to sleep.";
>    break;
> case 10:
>    echo "Good morning.";
>    break;
> case 22:
>    echo "Good night.";
>    break;
> }
> ?>
> 
> However, how do I do it if the variable is larger than a certain
> number? For instance, I want to say "Good night" if $hour is
> greater than 22?
> 
> Thanks in advance.
> 
> Dotan Cohen
> http://lyricslist.com/lyrics/biography/327/martin_ricky.php
> Martin, Ricky Song Lyrics and Biography
> 
> -- 
> fedora-list mailing list
> fedora-list@xxxxxxxxxx
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1

iQA/AwUBQ528pHv40fZIKe3PEQJ3yACgkJdQbk+J5My5Bq+21elEVtoDwswAoKpg
qY6LRZJjwS2xyn1z7Jcy3n9r
=RpsI
-----END PGP SIGNATURE-----


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux