coldfusion Variables Using cfparam

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The <cfparam> tag creates a variable if it does not already exist. You can assign a default value using the default attribute. This can be used if you want to create a variable, but don't want to overwrite it if it has been previously created elsewhere.

Here the variable hasn't been set previously, so it will be assigned with the <cfparam> tag.

<cfparam name="firstName" default="Justin">
<cfoutput>
    Hello #firstName#
</cfoutput>

Here the variable has already been assigned using the <cfset> tag, so this value will override the default value in the <cfparam> tag.

<cfset firstname="Justin">

<cfparam name="firstName" default="Barney">
<cfoutput>
    Hello #firstName#
</cfoutput>


Got any coldfusion Question?