note 97832 added to control-structures.switch

From: Date: Tue, 11 May 2010 09:29:47 +0000
Subject: note 97832 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-169139@lists.php.net to get a copy of this message
"loose comparison" means that switch won't check the type. switch will only compare values: <?php if('a string' == 0) echo 'a string is 0' . PHP_EOL; if('a string' === 0) echo 'but you will never see this' . PHP_EOL; switch(0){ case 'a string': echo 'a string' . PHP_EOL; case 'another string': echo 'another string' . PHP_EOL; } if('a string' == true) echo 'a string is TRUE' . PHP_EOL; if('a string' === true) echo 'but you will never see this' . PHP_EOL; switch(true){ case 'a string': echo 'a string' . PHP_EOL; case 'another string': echo 'another string' . PHP_EOL; } ?> will output: a string is 0 a string another string a string is TRUE a string another string ---- Server IP: 217.160.235.204 Probable Submitter: 80.152.220.156 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- https://master.php.net/note/edit/97832 Del: integrated -- https://master.php.net/note/delete/97832/integrated Del: useless -- https://master.php.net/note/delete/97832/useless Del: bad code -- https://master.php.net/note/delete/97832/bad+code Del: spam -- https://master.php.net/note/delete/97832/spam Del: non-english -- https://master.php.net/note/delete/97832/non-english Del: in docs -- https://master.php.net/note/delete/97832/in+docs Del: other reasons-- https://master.php.net/note/delete/97832 Reject -- https://master.php.net/note/reject/97832 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169139) next »