I see all three notations used frequently, and I'm wondering what the differences are between them:
<cfset var foo = "bar" />
<cfset local.foo = "bar" />
<cfset variables.foo = "bar" />
<cfset arguments.foo = "bar" />
var and local are the same scope and they are available only to the method/function in which they are declared. The local scope is new to CF 9 before that you used var to create variables that only existed in the method.
Variables is available to the entire cfc or cfm page in which they are declared and any included templates.
arguments is used for arguments passed into a method/function and only exists with in it.
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