标签:png mamicode info alt nbsp decode echo put obj
代码:
/** * 控制台输出 * @param $var * @param string $level */ function console($var,$level = ‘log‘) { if(is_array($var) || is_object($var)){ $output = json_encode($var); $jsonDecode = json_decode($output); if(empty($jsonDecode) && !empty($var)){ echo "<script>console.{$level}(‘不支持输出‘)</script>"; return; } }elseif(is_string($var)){ $output = ‘"‘.$var.‘"‘; }else{ $output = $var; } echo "<script>console.{$level}({$output})</script>"; return; }
效果:
标签:png mamicode info alt nbsp decode echo put obj
原文地址:https://www.cnblogs.com/wordblog/p/11330383.html