|
Fusebox
|
The set verb does just what it might be expected to do: it sets a variable. It has two required attributes, name and value. Here are some examples: The first statement sets the variable, color, to the value, red. The second statement sets the variable, red, to the value maroon and the third statement sets the variable, deepred, to the value, darkred. All operate the same way you would expect dynamic variable setting in ColdFusion, the only restriction being that imposed by compliancy with XML rules wherein a limited set of characters, such as the ampersand (&), must be specified by their character entities, such as '&'. PHP variants of the dynamic variable settings set above: PHP Fusebox also allows you to set variables that aren't strings, such as arrays or booleans, using the 'evaluate' attribute: The first and second lines are functionally equivalent, however the second line is probably more desirable based on readability. Remember that any dynamic variables used in the value needs to be escaped using the backslash (), because the text within your value attribute will be wrapped inside an eval(). The set command also has an optional Boolean attribute of overwrite that is true by default. If you set it to false such as: then the variable will only be set if the variable is not defined when this command is encountered at runtime. As you may expect, you can easily scope variables in a set command. Here are some examples: In PHP you can use your regular array notation for setting scoped variables. The only thing you need to remember is that the $ sign should be left out: |
Add Comment