Search code examples
coldfusioncfdump

How can you see all the contents of a variable in a coldfusion template?


In PHP for example you can do:

<?= var_dump($myVariable); ?>

And see a dump of the entire variable with all it's available properties. How can you do this in a coldfusion template with a .cfm extension (in other words in the view layer not controller)?


Solution

  • You are looking for <cfdump var="#myVariable#">. If you use the script-syntax (cfscript), it's writeDump(myVariable);.

    Note that dumping within a function or component might not display anything due to how the output buffer works in CF. In this case, use the abort="true" attribute of cfdump or abort manually after the dump by placing <cfabort> (cftag) or abort; (cfscript).