Snippets

Create an account or login to be able to add, comment and rate snippets.

Navigation

Debug an object or variable (easy way)

This in the easiest way (I found) to debug an object (or variable).

In an action

$this->debugMessage(sprintf('<h1>object</h1><pre>%s</pre>', print_r(@$this->object, true)));

In a template

<?php use_helper('Debug') ?>
<?php echo debug_message(sprintf('<h1>object</h1><pre>%s</pre>', print_r(@$object, true))) ?>

Based on symfony book debug page.

by brikou on 2006-06-24, tagged debug  object 

Comments on this snippet

gravatar icon
#1 Loïc Vernet on 2007-12-20 at 12:08

Advanced version here : http://www.symfony-project.org/snippets/snippet/258

You need to create an account or log in to post a comment or rate this snippet.