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


PHP Debug::_dump方法代码示例

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


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

示例1: _dump

 /**
  * Helper for Debug::dump(), handles recursion in arrays and objects.
  * @param string $var
  * @param int $length
  * @param int $level
  * @return string
  */
 protected static function _dump($var, $length = 128, $level = 0)
 {
     if ($var === null) {
         return '<small>null</small>';
     } elseif (is_bool($var)) {
         return '<small>bool</small> ' . ($var ? 'TRUE' : 'FALSE');
     } elseif (is_float($var)) {
         return '<small>float</small> ' . $var;
     } elseif (is_resource($var)) {
         if (($type = get_resource_type($var)) === 'stream' and $meta = stream_get_meta_data($var)) {
             $meta = stream_get_meta_data($var);
             if (isset($meta['uri'])) {
                 return '<small>resource</small><span>(' . $type . ')</span> ' . htmlspecialchars($meta['uri'], ENT_NOQUOTES);
             }
         } else {
             return '<small>resource</small><span>(' . $type . ')</span>';
         }
     } elseif (is_string($var)) {
         // Encode the string
         $str = htmlspecialchars($var, ENT_NOQUOTES);
         return '<small>string</small><span>(' . strlen($var) . ')</span> "' . $str . '"';
     } elseif (is_array($var)) {
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         static $marker;
         if ($marker === null) {
             // Make a unique marker
             $marker = uniqid("");
         }
         if (empty($var)) {
             // Do nothing
         } elseif (isset($var[$marker])) {
             $output[] = "(" . EXIDO_EOL . "{$space}{$s}*RECURSION*" . EXIDO_EOL . "{$space})";
         } elseif ($level < 5) {
             $output[] = "<span>(";
             $var[$marker] = true;
             foreach ($var as $key => &$val) {
                 if ($key === $marker) {
                     continue;
                 }
                 if (!is_int($key)) {
                     $key = '"' . htmlspecialchars($key, ENT_NOQUOTES, __('__charset')) . '"';
                 }
                 $output[] = "{$space}{$s}{$key} => " . Debug::_dump($val, $length, $level + 1);
             }
             unset($var[$marker]);
             $output[] = "{$space})</span>";
         } else {
             // Depth too great
             $output[] = "(" . EXIDO_EOL . "{$space}{$s}..." . EXIDO_EOL . "{$space})";
         }
         return '<small>array</small><span>(' . count($var) . ')</span> ' . implode(EXIDO_EOL, $output);
     } elseif (is_object($var)) {
         // Copy the object as an array
         $array = (array) $var;
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         $hash = spl_object_hash($var);
         // Objects that are being dumped
         static $objects = array();
         if (empty($var)) {
             // Do nothing
         } elseif (isset($objects[$hash])) {
             $output[] = "{" . EXIDO_EOL . "{$space}{$s}*RECURSION*" . EXIDO_EOL . "{$space}}";
         } elseif ($level < 10) {
             $output[] = "<code>{";
             $objects[$hash] = true;
             foreach ($array as $key => &$val) {
                 if ($key[0] === "") {
                     // Determine if the access is protected or protected
                     $access = '<small>' . ($key[1] === '*' ? 'protected' : 'private') . '</small>';
                     // Remove the access level from the variable name
                     $key = substr($key, strrpos($key, "") + 1);
                 } else {
                     $access = '<small>public</small>';
                 }
                 $output[] = "{$space}{$s}{$access} {$key} => " . Debug::_dump($val, $length, $level + 1);
             }
             unset($objects[$hash]);
             $output[] = "{$space}}</code>";
         } else {
             // Depth too great
             $output[] = "{" . EXIDO_EOL . "{$space}{$s}..." . EXIDO_EOL . "{$space}}";
         }
         return '<small>object</small> <span>' . get_class($var) . '(' . count($array) . ')</span> ' . implode(EXIDO_EOL, $output);
     } else {
         return '<small>' . gettype($var) . '</small> ' . htmlspecialchars(print_r($var, true), ENT_NOQUOTES);
     }
 }
开发者ID:esironal,项目名称:exidoengine,代码行数:98,代码来源:debug.php

示例2: _dump

 /**
  * Helper for Debug::dump(), handles recursion in arrays and objects.
  *
  * @param   mixed    variable to dump
  * @param   integer  maximum length of strings
  * @param   integer  recursion level (internal)
  * @return  string
  */
 protected static function _dump(&$var, $length = 128, $level = 0)
 {
     if ($var === NULL) {
         return '<small>NULL</small>';
     } elseif (is_bool($var)) {
         return '<small>bool</small> ' . ($var ? 'TRUE' : 'FALSE');
     } elseif (is_float($var)) {
         return '<small>float</small> ' . $var;
     } elseif (is_resource($var)) {
         if (($type = get_resource_type($var)) === 'stream' and $meta = stream_get_meta_data($var)) {
             $meta = stream_get_meta_data($var);
             if (isset($meta['uri'])) {
                 $file = $meta['uri'];
                 if (function_exists('stream_is_local')) {
                     // Only exists on PHP >= 5.2.4
                     if (stream_is_local($file)) {
                         $file = Debug::path($file);
                     }
                 }
                 return '<small>resource</small><span>(' . $type . ')</span> ' . htmlspecialchars($file, ENT_NOQUOTES, Kohana::$charset);
             }
         } else {
             return '<small>resource</small><span>(' . $type . ')</span>';
         }
     } elseif (is_string($var)) {
         // Clean invalid multibyte characters. iconv is only invoked
         // if there are non ASCII characters in the string, so this
         // isn't too much of a hit.
         $var = UTF8::clean($var, Kohana::$charset);
         if (UTF8::strlen($var) > $length) {
             // Encode the truncated string
             $str = htmlspecialchars(UTF8::substr($var, 0, $length), ENT_NOQUOTES, Kohana::$charset) . '&nbsp;&hellip;';
         } else {
             // Encode the string
             $str = htmlspecialchars($var, ENT_NOQUOTES, Kohana::$charset);
         }
         return '<small>string</small><span>(' . strlen($var) . ')</span> "' . $str . '"';
     } elseif (is_array($var)) {
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         static $marker;
         if ($marker === NULL) {
             // Make a unique marker
             $marker = uniqid("");
         }
         if (empty($var)) {
             // Do nothing
         } elseif (isset($var[$marker])) {
             $output[] = "(\n{$space}{$s}*RECURSION*\n{$space})";
         } elseif ($level < 5) {
             $output[] = "<span>(";
             $var[$marker] = TRUE;
             foreach ($var as $key => &$val) {
                 if ($key === $marker) {
                     continue;
                 }
                 if (!is_int($key)) {
                     $key = '"' . htmlspecialchars($key, ENT_NOQUOTES, Kohana::$charset) . '"';
                 }
                 $output[] = "{$space}{$s}{$key} => " . Debug::_dump($val, $length, $level + 1);
             }
             unset($var[$marker]);
             $output[] = "{$space})</span>";
         } else {
             // Depth too great
             $output[] = "(\n{$space}{$s}...\n{$space})";
         }
         return '<small>array</small><span>(' . count($var) . ')</span> ' . implode("\n", $output);
     } elseif (is_object($var)) {
         // Copy the object as an array
         $array = (array) $var;
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         $hash = spl_object_hash($var);
         // Objects that are being dumped
         static $objects = array();
         if (empty($var)) {
             // Do nothing
         } elseif (isset($objects[$hash])) {
             $output[] = "{\n{$space}{$s}*RECURSION*\n{$space}}";
         } elseif ($level < 10) {
             $output[] = "<code>{";
             $objects[$hash] = TRUE;
             foreach ($array as $key => &$val) {
                 if ($key[0] === "") {
                     // Determine if the access is protected or protected
                     $access = '<small>' . ($key[1] === '*' ? 'protected' : 'private') . '</small>';
                     // Remove the access level from the variable name
                     $key = substr($key, strrpos($key, "") + 1);
                 } else {
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:ko3,代码行数:101,代码来源:debug.php

示例3: dump

 /**
  * Returns an HTML string of information about a single variable.
  *
  * Borrows heavily on concepts from the Debug class of [Nette](http://nettephp.com/).
  *
  * @param   mixed   $value           variable to dump
  * @param   integer $length          maximum length of strings
  * @param   integer $level_recursion recursion limit
  *
  * @return  string
  */
 public static function dump($value, $length = 128, $level_recursion = 10)
 {
     return Debug::_dump($value, $length, $level_recursion);
 }
开发者ID:s4urp8n,项目名称:kohana-admin,代码行数:15,代码来源:Debug.php

示例4: _dump

 /**
  * Helper for Debug::dump(), handles recursion in arrays and objects.
  *
  * @param   mixed   $var    variable to dump
  * @param   integer $length maximum length of strings
  * @param   integer $limit  recursion limit
  * @param   integer $level  current recursion level (internal usage only!)
  * @return  string
  */
 protected static function _dump(&$var, $length = 128, $limit = 10, $level = 0)
 {
     if ($var === null) {
         return '<small>null</small>';
     } elseif (is_int($var)) {
         return '<small>integer</small> <span class="int">' . $var . '</span>';
     } elseif (is_bool($var)) {
         return '<small>bool</small> <span class="bool">' . ($var ? 'true' : 'false') . '</span>';
     } elseif (is_float($var)) {
         return '<small>float</small> <span class="float">' . $var . '</span>';
     } elseif (is_resource($var)) {
         if (($type = get_resource_type($var)) === 'stream' && ($meta = stream_get_meta_data($var))) {
             $meta = stream_get_meta_data($var);
             if (isset($meta['uri'])) {
                 $file = $meta['uri'];
                 // Only exists on PHP >= 5.2.4
                 if (stream_is_local($file)) {
                     $file = Debug::path($file);
                 }
                 return '<small>resource</small><span>(' . $type . ')</span> ' . htmlspecialchars($file, ENT_NOQUOTES, \Phalcana\Phalcana::$charset);
             }
         } else {
             return '<small>resource</small><span>(' . $type . ')</span>';
         }
     } elseif (is_string($var)) {
         // Clean invalid multibyte characters. iconv is only invoked
         // if there are non ASCII characters in the string, so this
         // isn't too much of a hit.
         $var = UTF8::clean($var, \Phalcana\Phalcana::$charset);
         if (UTF8::strlen($var) > $length) {
             // Encode the truncated string
             $str = htmlspecialchars(UTF8::substr($var, 0, $length), ENT_NOQUOTES, \Phalcana\Phalcana::$charset) . '&nbsp;&hellip;';
             //$str = htmlspecialchars(substr($var, 0, $length), ENT_NOQUOTES, \Phalcana\Phalcana::$charset).'&nbsp;&hellip;';
         } else {
             // Encode the string
             $str = htmlspecialchars($var, ENT_NOQUOTES, \Phalcana\Phalcana::$charset);
         }
         return '<small>string</small><span class="len">(' . strlen($var) . ')</span> <span class="string">"' . $str . '"</span>';
     } elseif (is_array($var)) {
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         static $marker;
         if ($marker === null) {
             // Make a unique marker - force it to be alphanumeric so that it is always treated as a string array key
             $marker = uniqid("") . "x";
         }
         if (empty($var)) {
             // Do nothing
         } elseif (isset($var[$marker])) {
             $output[] = "(\n{$space}{$s}*RECURSION*\n{$space})";
         } elseif ($level < $limit) {
             $output[] = "<span>(";
             $var[$marker] = true;
             foreach ($var as $key => &$val) {
                 if ($key === $marker) {
                     continue;
                 }
                 if (!is_int($key)) {
                     $key = '<span class="string">"' . htmlspecialchars($key, ENT_NOQUOTES, \Phalcana\Phalcana::$charset) . '"</span>';
                 } else {
                     $key = '<span class="int">' . $key . '</span>';
                 }
                 $output[] = "{$space}{$s}{$key} <span class=\"pointer\">=></span> " . Debug::_dump($val, $length, $limit, $level + 1);
             }
             unset($var[$marker]);
             $output[] = "{$space})</span>";
         } else {
             // Depth too great
             $output[] = "(\n{$space}{$s}...\n{$space})";
         }
         return '<small>array</small><span class="len">(' . count($var) . ')</span> ' . implode("\n", $output);
     } elseif (is_object($var)) {
         // Copy the object as an array
         $array = (array) $var;
         $output = array();
         // Indentation for this variable
         $space = str_repeat($s = '    ', $level);
         $hash = spl_object_hash($var);
         // Objects that are being dumped
         static $objects = array();
         if (empty($var)) {
             // Do nothing
         } elseif ($var instanceof \Phalcon\DI) {
             $output[] = "{\n{$space}{$s}*DEPENDENCY INJECTOR IGNORED*\n{$space}}";
         } elseif (isset($objects[$hash])) {
             $output[] = "{\n{$space}{$s}*RECURSION*\n{$space}}";
         } elseif ($level < $limit) {
             $output[] = "<code>{";
             $objects[$hash] = true;
             foreach ($array as $key => &$val) {
//.........这里部分代码省略.........
开发者ID:braf,项目名称:phalcana-core,代码行数:101,代码来源:Debug.php

示例5: _dump

 protected static function _dump(&$var, $length = 128, $limit = 10, $level = 0)
 {
     if ($var === NULL) {
         return "<small>NULL</small>";
     } elseif (is_bool($var)) {
         return "<small>bool</small> " . ($var ? "TRUE" : "FALSE");
     } elseif (is_float($var)) {
         return "<small>float</small> " . $var;
     } elseif (is_resource($var)) {
         if (($type = get_resource_type($var)) === "stream" and $meta = stream_get_meta_data($var)) {
             $meta = stream_get_meta_data($var);
             if (isset($meta["uri"])) {
                 $file = $meta["uri"];
                 if (function_exists("stream_is_local")) {
                     // Only exists on PHP >= 5.2.4
                     if (stream_is_local($file)) {
                         $file = Debug::path($file);
                     }
                 }
                 return "<small>resource</small><span>(" . $type . ")</span> " . htmlspecialchars($file, ENT_NOQUOTES, JsonApiApplication::$charset);
             }
         } else {
             return "<small>resource</small><span>(" . $type . ")</span>";
         }
     } elseif (is_string($var)) {
         $var = UTF8::clean($var, JsonApiApplication::$charset);
         if (UTF8::strlen($var) > $length) {
             $str = htmlspecialchars(UTF8::substr($var, 0, $length), ENT_NOQUOTES, JsonApiApplication::$charset) . "&nbsp;&hellip;";
         } else {
             $str = htmlspecialchars($var, ENT_NOQUOTES, JsonApiApplication::$charset);
         }
         return '<small>string</small><span>(' . strlen($var) . ')</span> "' . $str . '"';
     } elseif (is_array($var)) {
         $output = array();
         $space = str_repeat($s = "    ", $level);
         static $marker;
         if ($marker === NULL) {
             $marker = uniqid("") . "x";
         }
         if (empty($var)) {
             // Do nothing
         } elseif (isset($var[$marker])) {
             $output[] = "(\n{$space}{$s}*RECURSION*\n{$space})";
         } elseif ($level < $limit) {
             $output[] = "<span>(";
             $var[$marker] = TRUE;
             foreach ($var as $key => &$val) {
                 if ($key === $marker) {
                     continue;
                 }
                 if (!is_int($key)) {
                     $key = '"' . htmlspecialchars($key, ENT_NOQUOTES, JsonApiApplication::$charset) . '"';
                 }
                 $output[] = "{$space}{$s}{$key} => " . Debug::_dump($val, $length, $limit, $level + 1);
             }
             unset($var[$marker]);
             $output[] = "{$space})</span>";
         } else {
             $output[] = "(\n{$space}{$s}...\n{$space})";
         }
         return "<small>array</small><span>(" . count($var) . ")</span> " . implode("\n", $output);
     } elseif (is_object($var)) {
         $array = (array) $var;
         $output = array();
         $space = str_repeat($s = "    ", $level);
         $hash = spl_object_hash($var);
         static $objects = array();
         if (empty($var)) {
             // Do nothing
         } elseif (isset($objects[$hash])) {
             $output[] = "{\n{$space}{$s}*RECURSION*\n{$space}}";
         } elseif ($level < $limit) {
             $output[] = "<code>{";
             $objects[$hash] = TRUE;
             foreach ($array as $key => &$val) {
                 if ($key[0] === "") {
                     $access = "<small>" . ($key[1] === "*" ? "protected" : "private") . "</small>";
                     $key = substr($key, strrpos($key, "") + 1);
                 } else {
                     $access = "<small>public</small>";
                 }
                 $output[] = "{$space}{$s}{$access} {$key} => " . Debug::_dump($val, $length, $limit, $level + 1);
             }
             unset($objects[$hash]);
             $output[] = "{$space}}</code>";
         } else {
             // Depth too great
             $output[] = "{\n{$space}{$s}...\n{$space}}";
         }
         return "<small>object</small> <span>" . get_class($var) . "(" . count($array) . ")</span> " . implode("\n", $output);
     } else {
         return "<small>" . gettype($var) . "</small> " . htmlspecialchars(print_r($var, TRUE), ENT_NOQUOTES, JsonApiApplication::$charset);
     }
 }
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:94,代码来源:Debug.php


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