Re: switch case madness

From: Date: Wed, 19 Jan 2011 03:36:45 +0000
Subject: Re: switch case madness
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-310849@lists.php.net to get a copy of this message
Hi, If it is a string "0", you should use: case "0". Because in PHP, 0 == false == null. You need to know the difference between == and ===. Regards, Dong Chen On Wed, Jan 19, 2011 at 2:30 PM, Donovan Brooke <lists@euca.us> wrote: > Hello, > > I must not understand PHP's switch/case.. > The case '0' below fires when $t_mssg = "" apparently. > Is this how it's suppose to work? I would think > it would only fire if it equaled "0". > > ---------- > print "-$t_mssg- <br />"; > > if (isset($t_mssg)) { > switch ($t_mssg) { > case 0: > echo '<p><span style="color:red;">Log In > Successful</span></p>'; > break; > } > } > ---------- > > TIA, > Donovan > > -- > D Brooke > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Regards, CHEN Dong

« previous php.general (#310849) next »