When debugging, it is often useful to be able to inspect the contents of a variable. Simple variables can be displayed by merely enclosing them within <cfoutput> tags, but more complex variables (for example, arrays and structures, which are explained in Chapters 14 and 15 respectively) cannot be displayed in this way. To solve this problem, you may use the <cfdump> tag, which displays a variable (even a complex nested variable) in a clean, easy-to-read format. You'd never actually use <cfdump> in final production code, but this tag is invaluable during development and debugging. For example, to display a single variable you could use the following code: <cfdump var="#TestVar#"> You may also use this tag to display sets of variables. For example, to display all variables in the REQUEST scope, you could do the following: <cfdump var="#REQUEST#"> TIP <cfdump> takes an expression as the value passed to VAR, not a variable name. To refer to a variable within the specified expression, #s must be used. |