Evaluates a string value to determine whether the variable named in it exists.
This function is an alternative to the ParameterExists function, which is deprecated.
True, if the variable is found, or, for a structure, if its key is defined; False, otherwise.
Returns False for an array or structure element referenced using bracket notation. For example, IsDefined("myArray[3]") always returns False, even if the array element myArray[3] has a value.
IsDefined("variable_name")
New in ColdFusion MX: this function can process only the following constructs:
mystruct.key
)Parameter | Description |
---|---|
variable_name |
String, enclosed in quotation marks. Name of variable to test for. |
When working with the URL and Form scopes, which are structures, the StructKeyExists
function can sometimes be used in place of this
function. The following blocks of code are equivalent:
<h3>IsDefined Example</h3> <cfif IsDefined("FORM.myString")> <p>Because the variable FORM.myString is defined, we can show its contents. This lets us put a FORM and its resulting action page in the same page, while using IsDefined to control the flow of page execution. <p>The value of "FORM.myString" is <B><I><cfoutput>#FORM.myString# </cfoutput></I></B> <cfelse> <p>During the first execution of this page, the variable "FORM.myString" is not yet defined, so it is not evaluated. </cfif> ...