0

How to Dump Vars

ColdFusion

CFDump is one of ColdFusion's best tags. Simply give it a variable and it will output the value no matter its type (array, structure, query, cfc, java, etc it can handle just about everything).

Often I will use it to output a scope like form or url or variables (be careful with this one though as all queries are in this scope by default). The one scope I have not been able to dump is var until yesterday when Jared Rypka-Hauer passed along a tip. To dump the var scope do this:

<cfdump var="#getPageContext().getVariableScope()#">

You may have to adjust the output attribute of your functions.

[UPDATE: 9/5/07: This only works on CF 7, click here for how to do this with ColdFusion 8]

tags:
ColdFusion
 
Um, yeah, I'm gonna have to go ahead and disagree with you there, Bob.

CFDUMP isn't one of ColdFusion's best tags. It *is* the best. At the very least, I suspect it's the most used. Not only do I use it every day, but I use it *a lot* every day. Seriously.

It's so good that folks are writing custom code to reproduce its functionality in PHP, JS and other languages. What's that they say about the sincerest form of flattery? :-)
 
posted 594 days ago
Add Comment Reply to: this comment OR this thread
 
Jeff Pratt said:
 
Uh, there's no code showing in the box above.
 
posted 454 days ago
Add Comment Reply to: this comment OR this thread
 
 
Oops. Fixed.
 
posted 453 days ago
Add Comment Reply to: this comment OR this thread
 
Wayne said:
 
Sam,

I think you have an error in your code above. You said it dumped the var scope. It doesn't, it only dumps the variable scope. The variable scope will dump just fine within a cfc, but the var scope won't dump even in the function that has access to it. Any idea how to dump it?

Wayne
 
posted 432 days ago
Add Comment Reply to: this comment OR this thread
 
 
Wayne,

Which version of CF are you running? See the update above for CF8.

This is also all undocumented so it may not work in all cases.
 
posted 425 days ago
Add Comment Reply to: this comment OR this thread
 

Search

About Me
I am a 32-year old Web Developer specializing in ColdFusion. I live and work in downtown Washington, DC with my wife and daughter. I work for Interfolio where we help people collect, deliver and showcase their life's work. Read more About Me

2007 CFeMmy Best Newcommer winner
As voted on by fellow CF Bloggers.