List Info

Thread: note 70009 added to control-structures.alternative-syntax




note 70009 added to control-structures.alternative-syntax
user name
2006-09-29 19:08:39
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-struc
tures.alternative-syntax.php
Edit        -- https://master
.php.net/note/edit/70009
Del: integrated  -- h
ttps://master.php.net/note/delete/70009/integrated
Del: useless     -- http
s://master.php.net/note/delete/70009/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/70009/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/70009
Reject      -- https://mast
er.php.net/note/reject/70009
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )