25 Nov
Posted by Ganesh H S , Bangalore, India as zend framework
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
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jul | ||||||
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
RSS feed for comments on this post · TrackBack URI
Leave a reply