AdobeStock_455007340

If It Looks Like A Structure It Might Not Be One

If you saw a variable named “user.login” would you assume it was a structure named “user” with a member named “login”? That’s a logical assumption to make, but it may be incorrect. In fact, even if you saw the code you’d not be able to know if “user” was a structure merely by looking at it. ColdFusion 4 (and ColdFusion 5) allow you to create variables with periods in them, so if structure “user” does not exist creates a variable named “user.login”, not a structure member named “login”. This behavior may change in a future versions of ColdFusion, so for now your best bet is to not use periods in variable names. And if unsure, use the IsStruct() function to check if the variable that looks like a structure really is one. (Applies to: ColdFusion 4 (or later))

Leave a Reply