コード例 #1
0
ファイル: Debug.php プロジェクト: Balvan/nette
 /**
  * Dumps information about a variable in readable format.
  * @param  mixed  variable to dump
  * @param  bool   return output instead of printing it? (bypasses $productionMode)
  * @return mixed  variable itself or dump
  */
 public static function dump($var, $return = FALSE)
 {
     if (!$return && self::$productionMode) {
         return $var;
     }
     $output = "<pre class=\"nette-dump\">" . DebugHelpers::htmlDump($var) . "</pre>\n";
     if (!$return && self::$showLocation) {
         $trace = debug_backtrace();
         $i = isset($trace[1]['class']) && $trace[1]['class'] === __CLASS__ ? 1 : 0;
         if (isset($trace[$i]['file'], $trace[$i]['line'])) {
             $output = substr_replace($output, ' <small>' . htmlspecialchars("in file {$trace[$i]['file']} on line {$trace[$i]['line']}", ENT_NOQUOTES) . '</small>', -8, 0);
         }
     }
     if (self::$consoleMode) {
         $output = htmlspecialchars_decode(strip_tags($output), ENT_NOQUOTES);
     }
     if ($return) {
         return $output;
     } else {
         echo $output;
         return $var;
     }
 }