writeOutput

Appends text to the page-output stream.
This function writes to the page-output stream regardless of
conditions established by the cfsetting tag.

writeOutput(string) → returns String

Argument Reference for the writeOutput function

string

Required: Yes
A string, or a variable that contains one

encodeFor

Required: No
CF 2016+ Wraps the result with an encodeFor function. Values:
  • html
  • htmlattribute
  • javascript
  • css
  • xml
  • xmlattribute
  • url
  • xpath
  • ldap
  • dn

Examples sample code invoking the writeOutput function


Output the literal string "Hello World"

writeOutput("Hello World");

Output the equivalent string as a variable

greeting = "Hello World";
writeOutput(greeting);

Using the encodeFor argument

CF 2016+ Passing in html to the encodeFor argument wraps the result with a call to encodeForHTML.

name = "Pete";
writeOutput("Hello " & name, "html");

Expected Result: Hello Pete


Fork me on GitHub