note 62355 added to control-structures.switch

From: Date: Sun, 26 Feb 2006 01:23:13 +0000
Subject: note 62355 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-104444@lists.php.net to get a copy of this message
Normally, one places a variable in the switch expression to be compared to any number of expicit values in the case expressions. This is how it is documented above and how it is described in all books I have read. However, you can evaluate any expression in the switch expression to match any expression in the case expressions. Most notably, when you have a permutation of values that must be checked you can simply put TRUE in the switch expression and any complex expression that returns TRUE (or FALSE) in the case expressions. I did not see this in the documentation or in any books I have read, but it is extremely useful. (I had a nicer post with some nice example code, but this system gobbled all the returns into the ascii values creating too long lines.) ---- Server IP: 66.163.161.117 Probable Submitter: 64.13.21.130 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- http://master.php.net/note/edit/62355 Del: integrated -- http://master.php.net/note/delete/62355/integrated Del: useless -- http://master.php.net/note/delete/62355/useless Del: bad code -- http://master.php.net/note/delete/62355/bad+code Del: spam -- http://master.php.net/note/delete/62355/spam Del: non-english -- http://master.php.net/note/delete/62355/non-english Del: in docs -- http://master.php.net/note/delete/62355/in+docs Del: other reasons-- http://master.php.net/note/delete/62355 Reject -- http://master.php.net/note/reject/62355 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104444) next »