Tag Archives: Debugging

Debugging in Zend Framework

Perhaps “debugging” is a bit too strong. However when you’re dumping an array in PHP, you’d probably prefer the print_r or var_dump.

echo '<pre>';
print_r($array);
echo '</pre>';

But did you know that in Zend Framework there’s a built in Zend_Debug?

Zend_Debug::dump($array);

Does pretty much the same thing!

Write human readable debug info!

It’s a common begginer’s developer mistake to write some fullish debug info like “i’m in the IF”, or even worse – “test”. Of course when debugging you don’t get any aditional information. You know only that – you’re in the IF statement!? What a good news! That doesn’t tell you much, isn’t it?

Another bad way to debug is to dump only ids from some database table or loop index. At least write something before that, something like:

alert('on the: ' + index + ' happened something!');

that gives you more and can improve your work so much.