漂亮的印刷品
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了漂亮的印刷品相关的知识,希望对你有一定的参考价值。
<?php $GLOBALS['ppr_mode'] = 'on'; function ppr_set_mode($mode) { // mode = html | off | log $GLOBALS['ppr_mode'] = $mode; } function ppr() { if ($GLOBALS['ppr_mode'] == 'off') { return; } $line = $bt[0]['line']; $context = "ppr from $file($line) "; $html = _ppr_get_html($args); if ($GLOBALS['ppr_mode'] == 'log') { $html = $context . $html; } else { echo _ppr_get_style(); echo '<pre class="ppr">'; echo $context; echo $html; echo '</pre>'; } } function ppr_table($rows) { if ($GLOBALS['ppr_mode'] != 'html') { return; } echo _ppr_get_style(); echo '<pre class="ppr">[Empty Table]</pre>'; return; } echo '<pre class="ppr"><table class="ppr-rs" border="1"><tr>'; foreach ($rows[0] as $th => $v) { echo "<th>$th</th>"; } echo '</tr>'; foreach ($rows as $row) { echo '<tr>'; foreach ($row as $value) { echo '<td>' . _ppr_get_html($value, 1) . '</td>'; } echo '</tr>'; } echo '</table></pre>'; } function _ppr_get_object_vars($obj, $dump = '') { return $obj->pprGetObjectVars($dump); } return $props; } function _ppr_format_args($args) { $args = $args[0]; } else { foreach ($args as $i => $a) { $newArgs["@arg$i"] = $a; } $args = $newArgs; } return $args; } $out = ''; if ($val === false || $val === true) { $out .= _ppr_get_html_bool($val); } elseif ($val === null) { $out .= _ppr_get_html_null(); } $out .= _ppr_get_html_resource($val); } $out .= _ppr_get_html_array($val, $_maxDepth, $_level, $_isInObject, $_objIdCache); } $out .= _ppr_get_html_object($val, $_maxDepth, $_level, $_isInObject, $_objIdCache); } $out .= _ppr_get_html_float($val); } $out .= _ppr_get_html_int($val); } else { $out .= _ppr_get_html_string($val); } if (!$_isInObject) { $out .= "<br />"; } return $out; } function _ppr_get_html_bool($val) { return '<span class="ppr-bool">' . ($val ? 'true' : 'false') . '</span>'; } function _ppr_get_html_null() { return '<span class="ppr-null">null</span>'; } function _ppr_get_html_resource($val) { return '<span class="ppr-resource">Resource #' . $match[1] . ' <span class="ppr-resource-type">'.$match[2].'</span></span>'; } function _ppr_get_html_array($val, $_maxDepth=16, $_level=0, $_isInObject=false, &$_objIdCache=array()) { $out = ''; if ($_maxDepth == 0) { $out .= '<span class="ppr-array">Array <span class="ppr-parens">(</span> <span class="ppr-max">Max Depth</span> <span class="ppr-parens">)</span></span>'; } else { if (!$_isInObject) { $out .= '<span class="ppr-array">Array <span class="ppr-parens">(</span></span><br />'; } foreach ($val as $k => $v) { $out .= $indentNext . '<span class="ppr-bracket">[<span class="ppr-array-key">' . htmlentities((string) $k,ENT_QUOTES,'utf-8') . '</span>]</span>'; $out .= ' <span class="ppr-arrow">=></span> ' . _ppr_get_html($v, $_maxDepth-1, $_level+1, false, $_objIdCache); } if (!$_isInObject) { $out .= $indent . '<span class="ppr-parens">)</span>'; } } return $out; } function _ppr_get_html_object($val, $_maxDepth=16, $_level=0, $_isInObject=false, &$_objIdCache=array()) { $out = ''; $class = $match[1]; $id = $match[2]; $out .= '<span class="ppr-object">Object #' . $id .' <span class="ppr-class">'.$class.'</span> <span class="ppr-brace">{</span> <span class="ppr-max">'.$text.'</span> <span class="ppr-brace">}</span></span>'; } else { $_objIdCache[$id] = 1; $props = _ppr_get_object_vars($val, $dump); $out .= '<span class="ppr-object">Object #' . $id .' <span class="ppr-class">'.$class.'</span> <span class="ppr-brace">{</span></span>'; $out .= "<br />"; $out .= _ppr_get_html($props,$_maxDepth-1,$_level,true,$_objIdCache); $out .= $indent; } $out .= '<span class="ppr-brace">}</span>'; } return $out; } function _ppr_get_html_float($val) { return '<span class="ppr-float">' . $val . '</span>'; } function _ppr_get_html_int($val) { return '<span class="ppr-int">' . $val . '</span>'; } function _ppr_get_html_string($val) { return '<span class="ppr-string"><span class="ppr-lquot">“</span>' . htmlentities((string) $val,ENT_QUOTES) . '<span class="ppr-rquot">”</span></span>'; } function _ppr_get_style() { static $style_printed; if ($style_printed) { return ''; } $style_printed = true; return ' <style type="text/css" media="screen"> pre.ppr { font-family: "Bitstream Vera Sans Mono", Consolas, "Courier New", monospace; font-size: 12px; line-height: 130%; word-wrap: break-word; /* IE 5.5 - 7 */ white-space: pre-wrap; /* IE8, EOMB */ background-color: rgb(255,255,255); background-color: rgba(255,255,255,0.92); border: 1px solid #888; padding: 5px; text-align: left; clear: both; } .ppr-array, .ppr-object, .ppr-resource { font-style: italic; } .ppr-brace, .ppr-parens { font-style: normal; } .ppr-string { color: #008800; font-weight: normal; } .ppr-lquot { color: #777; font-family: "Times New Roman", Times, serif; font-weight: bold; font-size: 10px; margin-right: 2px; } .ppr-rquot { color: #777; font-family: "Times New Roman", Times, serif; font-weight: bold; font-size: 10px; margin-left: 2px; } .ppr-arrow { color: #777; font-weight: bold; } .ppr-array-key { color: #303030; font-weight: normal; } .ppr-class, .ppr-resource-type { color: #0055ee; font-weight: bold; font-style: normal; } .ppr-null { color: #0000ee; font-style: italic; } .ppr-bool { color: #dd7700; font-style: italic; } .ppr-bracket { color: #888; } .ppr-float { color: #2200ee; font-weight: bold; } .ppr-int { color: #cc0000; font-weight: bold; } .ppr-max { text-transform: uppercase; font-style: italic; color: #bb6666; font-weight: bold; } </style>'; } function _ppr_html_to_plain($html) { return $str; }
以上是关于漂亮的印刷品的主要内容,如果未能解决你的问题,请参考以下文章