Evaluates a string value to determine whether the variable named in it exists. Returns TRUE if the variable is found, FALSE if not found.
IsDefined
is an alternative to the ParameterExists
function, eliminating the need for cumbersome expressions used to test for the existence of a variable:
Evaluate("ParameterExists(#var_name#)")
IsDefined("variable_name")
Parameter |
Description |
---|---|
variable_name |
A string value. The name of the variable to test for. The value must be enclosed in quotation marks. |
<!--- This example shows the use of IsDefined ---> <html> <head> <title> IsDefined Example </title> </head> <body bgcolor = silver> <H3>IsDefined Example</H3> <cfif IsDefined("FORM.myString")> <P>Because the variable FORM.myString has been defined, we can now show its contents. This construction allows us to place a FORM and its resulting action template in the same template, while using IsDefined to control the flow of template execution. <P>The value of "FORM.myString" is <B><I><cfoutput>#FORM.myString# </cfoutput></I></B> <cfelse> <P>During the first time through this template, the variable "FORM.myString" has not yet been defined, so it is not evaluated. </cfif> ... </body> </html>