switch issue

From: Date: Sun, 06 Jan 2008 22:29:34 +0000
Subject: switch issue
Groups: php.db 
Request: Send a blank email to php-db+get-44486@lists.php.net to get a copy of this message
Hello all, Having a problem with the behaviour of switch when mixing variable types. Eg <?php $page = 'review'; switch ($page) { case 0: echo "0"; break; case 'review': echo "review"; break; } ?> this code interprets $page as 0 in the switch. It's not a problem to alter 'review' to a number, just less elegant. Can anybody shed a little light on mixed variable types in switch statements please? While browsing the manual I noticed it performs "loose comparison" but that seems to be the same as == ? Many thanks, Andy

« previous php.db (#44486) next »