Using structKeyExists Rather Than isDefined

If you have ever tried using the isDefined function like this:

<cfif isDefined("url['foo']")>

Then you have probably seen this error:

Parameter 1 of function IsDefined, which is now “url[‘foo’]”, must be a syntactically valid variable name.

In situations where you either have to use bracketed syntax, or simply prefer it, try using the structKeyExists function instead, like this:

<cfif structKeyExists(url, "foo")>

Since variable scopes are actually structs, the above syntax works with all scopes exactly like the isDefined function would.