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; False, otherwise.
IsDefined(variable)
ColdFusion (2018 release): Introduced named parameters.
ColdFusion MX: Changed behavior: this function can process only the following constructs:
Parameter |
Description |
---|---|
variable |
String, enclosed in quotation marks. Name of variable to test for. |
Passing an array entry, such as myArray3 to this function causes an error. To check whether a specific entry exists in an array, use the ArrayIsDefined function.You can test whether a specific key exists in a structure by using this function or the StructKeyExists function. For example, when working with scopes that ColdFusion exposes as structures, the StructKeyExists function can sometimes replace this function. The following lines are equivalent:
if(isDefined("form.myVariable")) if(structKeyExists(form,"myVariable"))
<cfscript> myarray=["1","4","23","5","54"]; for(i=1; i <= arrayLen(myarray); i++){ writeoutput(myarray[i] & "<br>"); } writeOutput(isDefined("myarray")) </cfscript>
Output
1
4
23
5
54
YES
Sign in to your account