Reputation: 113
I'm working with ColdFusion and CFScript. At the moment I've no problems, but noticed that I can call values in 3 ways:
Value
'Value'
'#Value#'
What are the differences between them? Thanks in advance!
Upvotes: 0
Views: 51
Reputation: 7833
Value
CF searches for a variable called Value
(case insensitive) starting with the VARIABLES
scope and then progressing through other scopes (like URL
and FORM
), stopping at the first variable found.
'Value'
A literal string with the characters V
, a
, l
, u
and e
.
'#Value#'
A string where Value
will be evaluated (CF evalautes stuff between #
). If the variable Value
(case insensitive) is a so called simple value
, the variable will be cast to a string. Otherwise, an exception is thrown since non-simple (ie complex ) values are not automatically cast as strings. This is basically equivalent to '' & Value & ''
(string concatenation).
Value = 'Hello World !!';
writeOutput(Value);
>> Hello World !!
writeOutput('Value');
>> Value
writeOutput('#Value#');
>> Hello World !!
writeOutput( evaluate('Value') );
>> Hello World !!
Upvotes: 2