22.08.2013 Views

ColdFusion Developer's Guide

ColdFusion Developer's Guide

ColdFusion Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />

Creating variables with periods<br />

You should avoid creating the names of variables (except for dot notation in structures) that<br />

include periods. However, <strong>ColdFusion</strong> provides mechanisms for handling cases where you<br />

must do so, for example, to maintain compatibility with names of variables in external data<br />

sources or to integrate your application with existing code that uses periods in variable names.<br />

The following sections describe how to create simple variable names that include periods.<br />

Using brackets to create variables with periods<br />

You can create a variable name that includes periods by using associative array structure<br />

notation, as described in Chapter 5, “Structure notation.” To do so, you must do the<br />

following:<br />

■ Refer to the variable as part of a structure. You can always do this, because <strong>ColdFusion</strong><br />

considers all scopes to be structures. For more information on scopes, see “About scopes”<br />

on page 72.<br />

■ Put the variable name that must include a period inside square brackets and single- or<br />

double-quotation marks.<br />

The following example shows this technique:<br />

<br />

<br />

<br />

My.Variable.With.Periods is: #My.Variable.With.Periods#<br />

Request.Another.Variable.With.Periods is:<br />

#Request.Another.Variable.With.Periods#<br />

<br />

Creating Client and Cookie variables with periods<br />

To create a Client or Cookie variable with a name that includes one or more periods, simply<br />

assign the variable a value. For example, the following line creates a Cookie named<br />

User.Preferences.CreditCard:<br />

<br />

64 Using <strong>ColdFusion</strong> Variables

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!