7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
23 * Concrete class for generating debug dumps related to the output source.
27 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
28 * @license http://framework.zend.com/license/new-bsd New BSD License
37 protected static $_sapi = null;
40 * Get the current value of the debug output environment.
41 * This defaults to the value of PHP_SAPI.
45 public static function getSapi()
47 if (self
::$_sapi === null) {
48 self
::$_sapi = PHP_SAPI
;
54 * Set the debug ouput environment.
55 * Setting a value of null causes Zend_Debug to use PHP_SAPI.
60 public static function setSapi($sapi)
66 * Debug helper function. This is a wrapper for var_dump() that adds
67 * the <pre /> tags, cleans up newlines and indents, and runs
68 * htmlentities() before output.
70 * @param mixed $var The variable to dump.
71 * @param string $label OPTIONAL Label to prepend to output.
72 * @param bool $echo OPTIONAL Echo output if true.
75 public static function dump($var, $label=null, $echo=true)
78 $label = ($label===null) ?
'' : rtrim($label) . ' ';
80 // var_dump the variable into a buffer and keep the output
83 $output = ob_get_clean();
85 // neaten the newlines and indents
86 $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
87 if (self
::getSapi() == 'cli') {
88 $output = PHP_EOL
. $label
92 if(!extension_loaded('xdebug')) {
93 $output = htmlspecialchars($output, ENT_QUOTES
);