本文整理匯總了PHP中Dumper::_hive方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dumper::_hive方法的具體用法?PHP Dumper::_hive怎麽用?PHP Dumper::_hive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Dumper
的用法示例。
在下文中一共展示了Dumper::_hive方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _vars
/**
* Render a dump for the properties of an array or objeect
*
* @param mixed &$data
* @access private
* @static
*/
private static function _vars(&$data)
{
$_is_object = is_object($data);
// test for references in order to
// prevent endless recursion loops
$_recursion_marker = Dumper::_marker();
if ($_is_object) {
if (($hash = spl_object_hash($data)) && isset(self::$objectRecursionProtection[$hash])) {
$_r = self::$objectRecursionProtection[$hash];
} else {
$_r = NULL;
}
} else {
$_r = isset($data[$_recursion_marker]) ? $data[$_recursion_marker] : null;
}
// recursion detected
if ($_r > 0) {
return Dumper::_recursion();
}
// stain it
Dumper::_hive($data);
// render it
$collapsed = Dumper::_isCollapsed(self::$_level, count($data) - 1);
if ($collapsed) {
$collapse_style = 'style="display: none;"';
} else {
$collapse_style = '';
}
print "<div class=\"dumper-nest\" {$collapse_style}>";
print "<ul class=\"dumper-node\">";
// we're descending one level deeper
self::$_level++;
// Object?? - use Reflection
if ($_is_object) {
$reflection = new ReflectionObject($data);
$properties = $reflection->getProperties();
foreach ($properties as $property) {
$prefix = null;
$setAccessible = false;
if ($property->isPrivate()) {
$setAccessible = true;
$prefix = 'private';
} elseif ($property->isProtected()) {
$setAccessible = true;
$prefix = 'protected';
} elseif ($property->isPublic()) {
$prefix = 'public';
}
$name = $property->getName();
if ($setAccessible) {
$property->setAccessible(true);
}
$value = $property->getValue($data);
Dumper::_dump($value, "<span>{$prefix}</span> {$name}");
if ($setAccessible) {
$property->setAccessible(false);
}
}
} else {
// keys
$keys = array_keys($data);
// iterate
foreach ($keys as $k) {
// skip marker
if ($k === $_recursion_marker) {
continue;
}
// get real value
$v =& $data[$k];
Dumper::_dump($v, $k);
}
}
print "</ul>\n</div>";
self::$_level--;
}