Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added more info about ColdFusion scopes.

  • Loading branch information...
commit 289c1e56348b07fb869e36344ef446808e6b7ee7 1 parent bdb7525
@boyzoid authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 Koans/AboutVariables.cfc
View
21 Koans/AboutVariables.cfc
@@ -14,6 +14,27 @@ component extends="mxunit.framework.TestCase"{
}
public void function testScoping(){
+ /*
+ ColdFusion has many 'scopes' in which it stored variables.
+ Each of these scopes is treated like a structure
+ When you do not 'scope' your varaible (such as calling session.foo instaed of just foo) ColdFusion
+ will seacrh through each of the scopes until it finds a variable with that name.
+ As such, you should ALWAYS scope your variables.
+
+ ColdFusion scopes include:
+ application: values stored in application scope are available in any .cfm or .cfc file under the same cfapplication
+ application scope is typically used to store information specifci to the application ans is availabel to all users.
+ session: values stored in session scope are available in any .cfm or .cfc file for the existing session
+ session scope is typically used to store information specific to a single user or session
+ request scope: values stored in the request scope area vailable in any .cfm or .cfc file during a sinlge request.
+ form scope: values from a form post are stored in the form scope and are available in any .cfm or .cfc file during a single request
+ url scope: values from the query string are stored in the url scope and are available in any .cfm or .cfc file during a single request
+ cgi scope: this read-only scope contains values about the request, such as user_agent, server_name, etc. and are available in any .cfm or .cfc file on every request.
+ arguments scope: arguments passed into a function are stored in a structue and are availabelo only inside the function to which they are defined.
+ If you do not use named arguments, the structure will contain keys that will be numbered with how many arguments are passed.
+ variables scope: variables that are set on .cfm or .cfc page are automatically stored in the variables scope if no other scope is given.
+
+ */
var foo = "local foo";
arguments.foo = "arg foo";
variables.foo = "variables foo";
Please sign in to comment.
Something went wrong with that request. Please try again.