00001 <?php
00031 class Zend_Debug
00032 {
00033
00037 protected static $_sapi = null;
00038
00045 public static function getSapi()
00046 {
00047 if (self::$_sapi === null) {
00048 self::$_sapi = PHP_SAPI;
00049 }
00050 return self::$_sapi;
00051 }
00052
00060 public static function setSapi($sapi)
00061 {
00062 self::$_sapi = $sapi;
00063 }
00064
00075 public static function dump($var, $label=null, $echo=true)
00076 {
00077
00078 $label = ($label===null) ? '' : rtrim($label) . ' ';
00079
00080
00081 ob_start();
00082 var_dump($var);
00083 $output = ob_get_clean();
00084
00085
00086 $output = preg_replace("/\]\=>\n(\s+)/m", "] => ", $output);
00087 if (self::getSapi() == 'cli') {
00088 $output = PHP_EOL . $label
00089 . PHP_EOL . $output
00090 . PHP_EOL;
00091 } else {
00092 if(!extension_loaded('xdebug')) {
00093 $output = htmlspecialchars($output, ENT_QUOTES);
00094 }
00095
00096 $output = '<pre>'
00097 . $label
00098 . $output
00099 . '</pre>';
00100 }
00101
00102 if ($echo) {
00103 echo($output);
00104 }
00105 return $output;
00106 }
00107
00108 }