Re: Switch statement Question

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

 



>"Alice Wei" <ajwei@xxxxxxxxxxxxx> wrote in message 
>news:SNT101-W587CD616331FC59B84834AF0C90@xxxxxxxxxx
>
>Hi,
>
>  I have a code snippet here as in the following:
>
>//Switch statements between the four options
>switch($string) {
>case "":
>$string= "NOT book.author='All'";
>break;
>default:
>$string= $string . "AND NOT book.author='All'";
>break;
>}
>  This code does work, but I am wondering if it is possible in the switch 
> statement clauses for me to do something like case does not equal to a 
> certain author name if I don't want $string with that content to >be 
> processed. or, do I always use default in this case?
>
>Thanks in advance.
>
>Alice
>_________________________________________________________________
>All-in-one security and maintenance for your PC. Get a free 90-day trial!
>http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail

You mean as in...

switch($string){
case "":
code
break;

case $string == 'some value':
code
break;

case in_array($string, $somearray):
code
break;

default:
code
};

yes...that is legal.  as long as the statment resolves to a boolean it will 
work.  It's not technically correct, but it does work. 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux