当前位置: 首页>>代码示例>>PHP>>正文


PHP Kint::mode方法代码示例

本文整理汇总了PHP中Kint::mode方法的典型用法代码示例。如果您正苦于以下问题:PHP Kint::mode方法的具体用法?PHP Kint::mode怎么用?PHP Kint::mode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kint的用法示例。


在下文中一共展示了Kint::mode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dump

 /**
  * Dump information about variables, accepts any number of parameters, supports modifiers:
  *
  *  clean up any output before kint and place the dump at the top of page:
  *   - Kint::dump()
  *  *****
  *  expand all nodes on display:
  *   ! Kint::dump()
  *  *****
  *  dump variables disregarding their depth:
  *   + Kint::dump()
  *  *****
  *  return output instead of displaying it (also disables ajax/cli detection):
  *   @ Kint::dump()
  *  *****
  *  disable ajax and cli auto-detection and just output as requested (plain/rich):
  *   ~ Kint::dump()
  *
  * Modifiers are supported by all dump wrapper functions, including Kint::trace(). Space is optional.
  *
  *
  * You can also use the following shorthand to display debug_backtrace():
  *   Kint::dump( 1 );
  *
  * Passing the result from debug_backtrace() to kint::dump() as a single parameter will display it as trace too:
  *   $trace = debug_backtrace( true );
  *   Kint::dump( $trace );
  *  Or simply:
  *   Kint::dump( debug_backtrace() );
  *
  *
  * @param mixed $data
  *
  * @return void|string
  */
 public static function dump($data = null)
 {
     if (!Kint::enabled()) {
         return '';
     }
     # find caller information
     list($names, $modifiers, $callee, $previousCaller, $miniTrace) = self::_getPassedNames(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace());
     # process modifiers: @, +, !, ~ and -
     if (strpos($modifiers, '-') !== false) {
         self::$_firstRun = true;
         while (ob_get_level()) {
             ob_end_clean();
         }
     }
     if (strpos($modifiers, '!') !== false) {
         $expandedByDefaultOldValue = self::$expandedByDefault;
         self::$expandedByDefault = true;
     }
     if (strpos($modifiers, '+') !== false) {
         $maxLevelsOldValue = self::$maxLevels;
         self::$maxLevels = false;
     }
     if (strpos($modifiers, '@') !== false) {
         $firstRunOldValue = self::$_firstRun;
         self::$_firstRun = true;
     }
     # disable mode detection
     if (strpos($modifiers, '@') !== false || strpos($modifiers, '~') === false) {
         $modeOldValue = self::$mode;
         $isAjaxOldValue = self::$_isAjax;
         if (self::$_detected === 'ajax') {
             self::$_isAjax = true;
         } elseif (self::$_detected === 'cli' && self::$cliDetection) {
             # cli detection is checked here as you can toggle the feature for individual dumps
             self::$mode = self::$cliColors ? 'cli' : 'whitespace';
         }
     }
     $decoratorsMap = array('cli' => 'Kint_Decorators_Cli', 'plain' => 'Kint_Decorators_Plain', 'rich' => 'Kint_Decorators_Rich', 'whitespace' => 'Kint_Decorators_Whitespace');
     $decorator = $decoratorsMap[self::$mode];
     $output = $decorator::wrapStart($callee);
     $trace = false;
     if ($names === array(null) && func_num_args() === 1 && $data === 1) {
         $trace = debug_backtrace(true);
         # Kint::dump(1) shorthand
     } elseif (func_num_args() === 1 && is_array($data)) {
         $trace = $data;
         # test if the single parameter is result of debug_backtrace()
     }
     $trace and $trace = self::_parseTrace($trace);
     if ($trace) {
         $output .= $decorator::decorateTrace($trace);
     } else {
         $data = func_num_args() === 0 ? array("[[no arguments passed]]") : func_get_args();
         foreach ($data as $k => $argument) {
             kintParser::reset();
             $output .= $decorator::decorate(kintParser::factory($argument, $names[$k]));
         }
     }
     $output .= $decorator::wrapEnd($callee, $miniTrace, $previousCaller);
     if (strpos($modifiers, '~') === false) {
         self::$mode = $modeOldValue;
     }
     if (strpos($modifiers, '!') !== false) {
         self::$expandedByDefault = $expandedByDefaultOldValue;
     }
//.........这里部分代码省略.........
开发者ID:ABaldwinHunter,项目名称:durhamatletico-cms,代码行数:101,代码来源:Kint.class.php


注:本文中的Kint::mode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。