The most useful function you will ever use in the Zend Framework

October 1st, 2007 by Jaybill McCarthy

Zend_Debug::dump() is a really handy part of the framework that simply dumps the contents of whatever you give it to print_r and wraps it in <pre></pre>.

I got tired of typing it out every time, so I added the following shorthand functions to my bootstrap file. (The only acceptable use of a function in a bootstrap, in my mind.)

  1.  
  2. require_once("Zend/Debug.php"); // next time we’re going to talk about __autoload()
  3.  
  4. /**
  5. * dd is a shorthand function for "dump and die". It takes whatever you give it and
  6. * spits it to d(), then dies.  Useful for debugging.
  7. */
  8.  
  9. function dd($val){
  10. d($val);
  11. die();
  12. }
  13.  
  14. /**
  15. * This is so I don’t have to keep typing Zend_Debug::dump($whatever);
  16. */
  17. function d($val){
  18. Zend_Debug::dump($val);
  19. }

Posted in Zend_Debug, zend, zend framework | 2 Comments »