Outputting Local Variables

Note To output the local variable that you created:
  1. Return to MyFirstPage.cfm in HomeSite.
  2. Add a CFOUTPUT block tag under the CFSET tag.
  3. Reference the ProductName local variable within the block:

    If you performed the procedures presented in the last chapter, then you have already referenced the ProductName local variable. Prefix the variable now.

  5. Save your changes.
  6. Your page should look like this now:

    <TITLE>My First Page</TITLE>
    <CFSET ProductName="ColdFusion">
  7. Refresh your page in the browser.
  8. View the page source in the browser.
  9. The CFML tags were processed on the server.

    The current variable value is returned as text to the browser.

  10. Return to HomeSite.
  11. Apply HTML formatting to make the ProductName value appear in bold:
  12. <CFOUTPUT>
  13. Add some text surrounding the local variable reference:
  14. <CFOUTPUT>
        The product name is <STRONG>#Variables.ProductName#</STRONG>.
  15. Save your changes.
  16. Refresh the page in the browser.
  17. The HTML formatting and text is returned to the browser.

  18. View the page source in the browser.
  19. The CFML tags were processed on the server.

Click here to see the Chapter 4 solution file that's delivered with this product.

Click here to see the code behind the scenes.

You have output the current value of a local variable. You will perform the same procedure to output other types of variables. Move on in this chapter to learn about how you work with and output CGI variables.