note 119854 added to control-structures.switch

From: Date: Wed, 07 Sep 2016 00:50:10 +0000
Subject: note 119854 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-206513@lists.php.net to get a copy of this message
Note the case statement does not have to compare with the switch statement. I sometimes use the switch statement to make complex logic more readable: <?php define('TRACK_CPI', true); define('TRACK_INV', true); define('PREFER_CPI_OVER_SINV', false); . . switch (1) { case (TRACK_CPI and PREFER_CPI_OVER_SINV and ($data_row['CPI_id'] != 0)): { . . break; } case (TRACK_CPI and (!PREFER_CPI_OVER_SINV) and ($data_row['SInv_id'] != 0)): { . . break; } case (TRACK_CPI and ($data_row['CPI_id'] != 0)): { . . break; } case (TRACK_INV and $data_row['SInv_id'] != 0): { . . break; } } ?> Hope this helps. ---- Server IP: 72.52.91.14 Probable Submitter: 2601:840:8001:c200:211:aff:fe58:db0f ---- Manual Page -- http://php.net/manual/en/control-structures.switch.php Edit -- https://master.php.net/note/edit/119854 Del: integrated -- https://master.php.net/note/delete/119854/integrated Del: useless -- https://master.php.net/note/delete/119854/useless Del: bad code -- https://master.php.net/note/delete/119854/bad+code Del: spam -- https://master.php.net/note/delete/119854/spam Del: non-english -- https://master.php.net/note/delete/119854/non-english Del: in docs -- https://master.php.net/note/delete/119854/in+docs Del: other reasons-- https://master.php.net/note/delete/119854 Reject -- https://master.php.net/note/reject/119854 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206513) next »