Zend debug is used for debugging purpose. The static method Zend_Debug::dump() prints or returns information about an expression, which is much similar of using var_dump.

Syntax is as below -

  <?php

// $var argument specifies the expression or variable
// $label argument is a string to be prepended to the output
// $echo argument specifies whether the output should be displayed or not.
Zend_Debug::dump($var, $label=null, $echo=true);
?>

Lets illustrate its advantage in the following example -

Lets define the application configuration variables in application/config.ini -

[staging]
show_errors = true

[production]
show_errors = false

//Lets write a script public/example.php, which illustrates the usage of zend dump

//In the following example, require_once “Zend/Loader.php”; is commented, so error is thrown and is dumped by Zend debug

//Error messages are only dumped in the development instace, this is controlled by ini config variable show_errors

<?php

// require_once "Zend/Loader.php";
require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini('application/config.ini', 'staging');

try
{
Zend_Loader::loadClass(Zend_Session);
}
catch (Zend_Exception $e)
{
Zend_Debug::dump($e->getMessage(), "Error cannot Load Zend session:",  $config->show_errors);
}

Reference Links:

http://ganeshhs.com/zend-framework/zend-framework-tutorial-part-4-zend-config

http://ganeshhs.com/zend-framework/zend-framework-tutorial-part-3-zend-loader

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Simpy
  • StumbleUpon
  • Technorati
  • YahooMyWeb