示例#1
0
    /**
     * Dump information about a variable
     *
     * @param mixed $data,...
     * @access public
     * @static
     */
    function dump($data)
    {
        // disabled ?
        //
        if (!krumo::_debug()) {
            return false;
        }
        // more arguments ?
        //
        if (func_num_args() > 1) {
            $_ = func_get_args();
            foreach ($_ as $d) {
                krumo::dump($d);
            }
            return;
        }
        // the css ?
        //
        krumo::_css();
        // find caller
        // DEVEL: we added array_reverse() so the proper file+line number is found.
        $_ = array_reverse(debug_backtrace());
        while ($d = array_pop($_)) {
            // DEVEL: changed if() condition below
            if (strpos(@$d['file'], 'devel') === FALSE && strpos(@$d['file'], 'krumo') === FALSE && @$d['class'] != 'krumo') {
                break;
            }
        }
        // the content
        //
        ?>
<div class="krumo-root">
	<ul class="krumo-node krumo-first">
		<?php 
        echo krumo::_dump($data);
        ?>
		<li class="krumo-footnote">
			<div class="krumo-version" style="white-space:nowrap;">
				<h6>Krumo version <?php 
        echo krumo::version();
        ?>
</h6> | <a
					href="http://krumo.sourceforge.net"
					target="_blank">http://krumo.sourceforge.net</a>
			</div>
		
		<?php 
        if (@$d['file']) {
            ?>
		<span class="krumo-call" style="white-space:nowrap;">
			Called from <code><?php 
            echo $d['file'];
            ?>
</code>,
				line <code><?php 
            echo $d['line'];
            ?>
</code></span>
		<?php 
        }
        ?>
		&nbsp;
		</li>
	</ul>
</div>
<?php 
        // flee the hive
        //
        $_recursion_marker = krumo::_marker();
        if ($hive =& krumo::_hive($dummy)) {
            foreach ($hive as $i => $bee) {
                if (is_object($bee)) {
                    unset($hive[$i]->{$_recursion_marker});
                } else {
                    unset($hive[$i][$_recursion_marker]);
                }
            }
        }
        // PHP 4.x.x array reference bug...
        //
        if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
            unset($GLOBALS[krumo::_marker()]);
        }
    }
示例#2
0
 /**
  * Dump information about a variable
  *
  * @param mixed $data,...
  * @access public
  * @static
  */
 public static function dump($data, $second = '')
 {
     if (Krumo::is_cli()) {
         print_r($data);
         exit;
     }
     static $setheader = null;
     if (empty($setheader) && ($setheader = 1)) {
         try {
             @header("Content-type: text/html; charset=utf-8");
         } catch (Exception $e) {
         }
     }
     // If we're capturing call dump() with just data and capture the output
     if ($second === KRUMO_RETURN) {
         ob_start();
         Krumo::dump($data);
         $str = ob_get_clean();
         return $str;
         // If we were given expand all, set the global variable
     } elseif ($second === KRUMO_EXPAND_ALL) {
         self::$expand_all = true;
         Krumo::dump($data);
         return true;
     }
     $clearObjectRecursionProtection = false;
     if (self::$objectRecursionProtection === NULL) {
         self::$objectRecursionProtection = array();
         $clearObjectRecursionProtection = true;
     }
     // disabled
     if (!Krumo::_debug()) {
         return false;
     }
     // more arguments
     if (func_num_args() > 1) {
         $_ = func_get_args();
         foreach ($_ as $d) {
             Krumo::dump($d);
         }
         return;
     }
     // find caller
     $_ = debug_backtrace();
     while ($d = array_pop($_)) {
         $callback = self::$lineNumberTestCallback;
         $function = strToLower($d['function']);
         if (in_array($function, array("krumo", "k", "kd")) || strToLower(@$d['class']) == 'krumo' || is_callable($callback) && $callback($d)) {
             break;
         }
     }
     $showVersion = Krumo::_config('display', 'show_version', TRUE);
     $showCallInfo = Krumo::_config('display', 'show_call_info', TRUE);
     $krumoUrl = 'https://github.com/oodle/krumo';
     //////////////////////
     // Start HTML header//
     //////////////////////
     print "<div class=\"krumo-root\">\n";
     print "\t<ul class=\"krumo-node krumo-first\">\n";
     // The actual item itself
     ob_start();
     print Krumo::_dump($data);
     print str_replace(ROOT, '~', ob_get_clean());
     if ($showVersion || $showCallInfo) {
         print "\t\t<li class=\"krumo-footnote\" onDblClick=\"toggle_expand_all();\">\n";
         if ($showCallInfo && isset($d['file']) && $d['file']) {
             print "<span class=\"krumo-call\" style=\"white-space:nowrap;\">";
             print "Called from <strong><code>" . str_replace(ROOT, '~', $d['file']) . "</code></strong>, ";
             print "line <strong><code>" . $d['line'] . "</code></strong></span>";
             print "<span class=\"krumo-call\"> { Time: " . number_format(microtime(true) - LARAVEL_START, 3) . 's }</span>';
         }
         if ($showVersion && 0) {
             $version = krumo::version();
             print "<span class=\"krumo-version\" style=\"white-space:nowrap;\">\n";
             print "<strong class=\"krumo-version-number\">Krumo version {$version}</strong> | <a href=\"{$krumoUrl}\" target=\"_blank\">{$krumoUrl}</a>\n";
             print "</span>\n";
         }
         print "</li>";
     }
     print "</ul></div>\n";
     print "<!-- Krumo - HTML -->\n\n";
     // Output the CSS and JavaScript AFTER the HTML
     krumo::_css();
     ////////////////////
     // End HTML header//
     ////////////////////
     // flee the hive
     $_recursion_marker = Krumo::_marker();
     if ($hive =& Krumo::_hive($dummy)) {
         foreach ($hive as $i => $bee) {
             if (is_object($bee)) {
                 if (($hash = spl_object_hash($bee)) && isset(self::$objectRecursionProtection[$hash])) {
                     unset(self::$objectRecursionProtection[$hash]);
                 }
             } elseif (isset($hive[$i]->{$_recursion_marker})) {
                 unset($hive[$i][$_recursion_marker]);
             }
         }
     }
     if ($clearObjectRecursionProtection) {
         self::$objectRecursionProtection = NULL;
     }
     // End of dump()
 }
示例#3
0
    /**
     * Dump information about a variable
     *
     * @param mixed $data,...
     * @access public
     * @static
     */
    public static function dump($data)
    {
        // disabled ?
        //
        if (!krumo::_debug()) {
            return false;
        }
        // more arguments ?
        //
        if (func_num_args() > 1) {
            $_ = func_get_args();
            foreach ($_ as $d) {
                krumo::dump($d);
            }
            return;
        }
        // the css ?
        //
        krumo::_css();
        // find caller
        //
        $_ = debug_backtrace();
        while ($d = array_pop($_)) {
            if (strToLower($d['function']) == 'krumo' || strToLower(@$d['class']) == 'krumo') {
                break;
            }
        }
        // the content
        //
        ?>
<div class="krumo-root">
	<ul class="krumo-node krumo-first">
		<?php 
        echo krumo::_dump($data);
        ?>
		<li class="krumo-footnote">
			<div class="krumo-version" style="white-space:nowrap;">
				<h6>腾迅微博API,PHP SDK <?php 
        echo krumo::version();
        ?>
</h6> | <a
					href="http://t.177wan.com/qq"
					target="_blank">http://t.177wan.com</a>
			</div>
		
		<?php 
        if (@$d['file']) {
            ?>
		<span class="krumo-call" style="white-space:nowrap;">
			Called from <code><?php 
            echo $_SERVER['PHP_SELF'];
            ?>
</code>,
				line <code><?php 
            echo $d['line'];
            ?>
</code></span>
		<?php 
        }
        ?>
		&nbsp;
		</li>
	</ul>
</div>
<?php 
        // flee the hive
        //
        $_recursion_marker = krumo::_marker();
        if ($hive =& krumo::_hive($dummy)) {
            foreach ($hive as $i => $bee) {
                if (is_object($bee)) {
                    unset($hive[$i]->{$_recursion_marker});
                } else {
                    unset($hive[$i][$_recursion_marker]);
                }
            }
        }
        // PHP 4.x.x array reference bug...
        //
        if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
            unset($GLOBALS[krumo::_marker()]);
        }
    }
 /**
  * Dump information about a variable
  *
  * @param mixed $data,...
  * @access public
  * @static
  */
 public static function dump($data, $capture = '')
 {
     // If we're capturing call dump() with just data and capture the output
     if ($capture === KRUMO_CAPTURE) {
         ob_start();
         krumo::dump($data);
         $str = ob_get_clean();
         return $str;
     }
     $clearObjectRecursionProtection = false;
     if (self::$objectRecursionProtection === NULL) {
         self::$objectRecursionProtection = array();
         $clearObjectRecursionProtection = true;
     }
     // disabled
     if (!krumo::_debug()) {
         return false;
     }
     // more arguments
     if (func_num_args() > 1) {
         $_ = func_get_args();
         foreach ($_ as $d) {
             krumo::dump($d);
         }
         return;
     }
     // the css
     krumo::_css();
     // find caller
     $_ = debug_backtrace();
     while ($d = array_pop($_)) {
         $callback = self::$lineNumberTestCallback;
         $function = strToLower($d['function']);
         if (in_array($function, array("krumo", "k", "kd")) || strToLower(@$d['class']) == 'krumo' || is_callable($callback) && $callback($d)) {
             break;
         }
     }
     $showVersion = krumo::_config('display', 'show_version', TRUE);
     $showCallInfo = krumo::_config('display', 'show_call_info', TRUE);
     $krumoUrl = 'https://github.com/oodle/krumo';
     //////////////////////
     // Start HTML header//
     //////////////////////
     print "<div class=\"krumo-root\">\n";
     print "\t<ul class=\"krumo-node krumo-first\">\n";
     // The actual item itself
     print krumo::_dump($data);
     if ($showVersion || $showCallInfo) {
         print "\t\t<li class=\"krumo-footnote\">\n";
         if ($showVersion) {
             $version = krumo::version();
             print "<div class=\"krumo-version\" style=\"white-space:nowrap;\">\n";
             print "<h6>Krumo version {$version}</h6> | <a href=\"{$krumoUrl}\"\ttarget=\"_blank\">{$krumoUrl}</a>\n";
             print "</div>\n";
         }
         if ($showCallInfo && isset($d['file']) && $d['file']) {
             print "<span class=\"krumo-call\" style=\"white-space:nowrap;\">";
             print "Called from <code>" . $d['file'] . "</code>, ";
             print "line <code>" . $d['line'] . "</code></span>";
         }
         print "</li>";
     }
     print "</ul></div>\n";
     print "<!-- Krumo - HTML -->\n\n";
     ////////////////////
     // End HTML header//
     ////////////////////
     // flee the hive
     $_recursion_marker = krumo::_marker();
     if ($hive =& krumo::_hive($dummy)) {
         foreach ($hive as $i => $bee) {
             if (is_object($bee)) {
                 if (($hash = spl_object_hash($bee)) && isset(self::$objectRecursionProtection[$hash])) {
                     unset(self::$objectRecursionProtection[$hash]);
                 }
             } elseif (isset($hive[$i]->{$_recursion_marker})) {
                 unset($hive[$i][$_recursion_marker]);
             }
         }
     }
     if ($clearObjectRecursionProtection) {
         self::$objectRecursionProtection = NULL;
     }
     // End of dump()
 }