Creating Local Variables

Note To create a local variable:
  1. Return to MyFirstPage.cfm in ColdFusion HomeSite.
  2. Below the begin BODY tag, create a local variable called ProductName and set its value to ColdFusion:
  3. <CFSET ProductName="ColdFusion">
    

    If you performed the procedures presented in the last chapter, then you already have this variable created.

  4. Save the file.
  5. Ctrl S saves the file.

    Your page should look like this:

    <HTML>
    <HEAD>
    <TITLE>My First Page</TITLE>
    </HEAD>
    <BODY>
    <STRONG>ColdFusion</STRONG>
    <CFSET ProductName="ColdFusion">
    </BODY>
    </HTML>
    
  6. Return to the browser and refresh http://127.0.0.1/CFDOCS/MyFirstPage.cfm.
  7. Ctrl R refreshes the page in the browser.

    The variable is not output to the page; its value is just stored with the page.

    You will learn how to output the variable value during the next procedure.

  8. View the page source in the browser.
  9. The CFML tag was processed on the server.

    Only HTML is returned to the browser.

Note Note:The CFPARAM tag can also be used to set and initialize variables. Refer to the CFML Language Reference for ColdFusion Express for more information.

You have created a local variable on your page. Move on in this chapter to learn how to reference a variable on an application page.