RE: [PHP] simplify if/then statement
| From: | Philip Olson | Date: | Sat, 27 Apr 2002 18:43:27 +0000 |
| Subject: | RE: [PHP] simplify if/then statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94932@lists.php.net to get a copy of this message | ||
I'd do something similar to this, along with
putting all states in an array to make sure
$state is actually a state (in_array). And
maybe you want to add guam :)
a) be sure $state is set, else load default
b) be sure $state is not bogus, else yell at them
c) be sure the $state file exists, if so, include
it else houston we have a problem
Regards,
Philip Olson
On Sat, 27 Apr 2002, Stuart Dallas wrote:
> $incfilename = "Calc".$state.".class.inc";
> if (file_exists($incfilename))
> include($incfilename);
> else
> echo "Please select a State.<br>\n";
>
> --
> Stuart
>
> -----Original Message-----
> From: Jim Long [mailto:jim@jimlong.net]
> Sent: 27 April 2002 20:00
> To: php
> Subject: [PHP] simplify if/then statement
>
>
> Hi,
>
> I've got the following statement for a state options menu.
> How can this be expressed in a simple manner for all 52 states?
>
>
> //choose state
>
> if ($state == "AL") {
>
> // include class
> include("CalcAL.class.inc");
> }
>
> else if ($state == "AR") {
>
> // include class
> include("CalcAR.class.inc");
> }
>
> else if ($state == "AZ") {
>
> // include class
> include("CalcAZ.class.inc");
> }
>
> else{
> echo "Please select a State.<br>\n";
> }
>
> Thank You Very Much,
>
> Jim Long
> --
> http://jimlong.net/web
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>