一个输出方法,显示输出文件-行数-数据类型-数据
/**
*输出信息
*/
function sd($data , $isDie = false)
{
$fileData = debug_backtrace();
ob_start();
print_r($data);
$info['content'] =ob_get_clean();
$str = '<pre style="padding:10px;border-radius:5px;background:#F5F5F5;border:1px solid #aaa;font-size:14px;line-height:18px;">';
$str .= "\r\n";
$str .= '<strong>FILE</strong>: ' . $fileData[0]['file'] . " <br />";
$str .= '<strong>LINE</strong>: ' . $fileData[0]['line'] . " <br />";
$str .= '<strong>TYPE</strong>: ' . gettype($data) . " <br />";
$str .= '<strong>CONTENT</strong>: ' . trim($info['content'], "\r\n");
$str .= "\r\n";
$str .= "</pre>";
echo $str;
$isDie === false ? false : die();
}
代码
$int = 123; $str = 'hello world'; $arr = array('hello','world'); sd($int); sd($str); sd($arr);
展示效果
FILE: /test/__controller.php LINE: 20 TYPE: integer CONTENT: 123
FILE: /test/__controller.php LINE: 21 TYPE: integer CONTENT: 123
FILE: /test/__controller.php LINE: 22 TYPE: array CONTENT: array(
[0] => hello
[1] => world
)

浙公网安备 33010602011771号