Re: Switch statement Question

From: Date: Fri, 30 Jan 2009 13:14:54 +0000
Subject: Re: Switch statement Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-287410@lists.php.net to get a copy of this message
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
Well I will have to mention that switch becomes if after all internally so you could always use the if statement. I am a great fan of switch but since eclipse fail to format correctly embedded switch statements I am starting to use the old all good if() since it is the same thing. It is a matter of style actually although switch is slightly slower (so slightly that you can't notice in any case). I think there was a thread in this list for this comparison a few days ago. -- Thodoris

« previous php.general (#287410) next »