O'Reilly logo

Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started by Charlie Arehart, Raymond Camden, Ben Forta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Revisiting Variables

Another important tag is <cfparam>. You won’t use this tag here, but in preparation for the next chapters, I’ll explain what this tag is and how it is used.

Earlier in this chapter, you used a function named IsDefined(), which is used to check whether a variable exists. You used IsDefined() to simply check for a variable’s existence, but what if you wanted to create a variable with a default value if it did not exist? You could do something similar to this:

<cfif NOT IsDefined("FirstName")>
 <cfset FirstName="Ben">
</cfif>

Why would you want to do this? Well, as a rule, you should not include data validation code in the middle of your core code. This is bad practice for several reasons, the most important of which are that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required