note 70009 deleted from control-structures.alternative-syntax by mgf
| From: | mgf@php.net | Date: | Thu, 28 Aug 2008 12:44:07 +0000 |
| Subject: | note 70009 deleted from control-structures.alternative-syntax by mgf | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143917@lists.php.net to get a copy of this message | ||
Note Submitter: Neil
----
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.