note 70009 added to control-structures.alternative-syntax

From: Date: Fri, 29 Sep 2006 19:08:39 +0000
Subject: note 70009 added to control-structures.alternative-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-117842@lists.php.net to get a copy of this message
as skippy noted above this is very useful stuff for interspersed php & html. Here is alternative syntax example using a bitwise comparison to set checkboxes on and off to prefill a permissions bitmask calculator form: <? $bitmask = 481683; ?> .... [yada yada yada].... <input type="checkbox" name="SOME_PERMISSION_VARIABLE" value="32768" <? echo($bitmask & 32768 ? "checked" : ""); ?>>Can perform some operation<br/> <input type="checkbox" name="SOME_OTHER_PERMISSION_VARIABLE" value="65536" <? echo($bitmask & 65536 ? "checked" : ""); ?>>Can perform some other operation<br/> You supply a bitmask, and it prechecks all the permissions the user has so you don't need to remember what they already have to recheck them all individually. It's much more elegant than traditional if's. ---- Server IP: 66.163.161.117 Probable Submitter: 66.240.11.2 ---- Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php Edit -- https://master.php.net/note/edit/70009 Del: integrated -- https://master.php.net/note/delete/70009/integrated Del: useless -- https://master.php.net/note/delete/70009/useless Del: bad code -- https://master.php.net/note/delete/70009/bad+code Del: spam -- https://master.php.net/note/delete/70009/spam Del: non-english -- https://master.php.net/note/delete/70009/non-english Del: in docs -- https://master.php.net/note/delete/70009/in+docs Del: other reasons-- https://master.php.net/note/delete/70009 Reject -- https://master.php.net/note/reject/70009 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117842) next »