Below is the code block, I am using.
<cfset variables.test1 = 'interface.temp1'>
<cfset variables.test2 = 'interface.temp2'>
<cfset variables.test3 = 'variables.' & variables.test2>
<cfset variables["#variables.test1#"] = 23>
<cfset "#variables.test3#" = 50>
<cfdump var="#variables#">
<cfdump var="#variables['interface.temp1']#">
The attached image describes the output, I am getting. The first cfdump displays the "interface.temp1" value as "undefined" and in the second cfdump it is displaying the value as "23". If you also look at the first cfdump, it is displaying all the variables in VARIABLES scope but there is no variable having the value as "23", then in the second cfdump from where is it getting the value as "23"?
Please help me to know the cause behind this.
I've cracked it. I write it up fully on my blog: "Odd behaviour with struct keys with dots in their names".
Basically once you have a substruct called interface
, which is - as @Leigh said - created by this:
<cfset "#variables.test3#" = 50>
Then ColdFusion (and, fwiw, Railo), get confused when trying to resolve struct keys that are prefixed with interface.
: it sees those references as references to keys within the interface
sub struct, rather than simply key names.
If you don't have that line of code above, then CF's able to see the dotted-key-named value just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With