PHP100 2019-03-27
代码如下:
<?php class WebConsole { private static function write($data, $type = 'info') { $method_types = array('error', 'info', 'log', 'warn'); $msg_type = '';(PS:T不错的PHP Q扣n:304224365,验证:csl) if(in_array($type, $method_types)) { $msg_type = sprintf("console.%s", $type); }else { $msg_type = sprintf("console.%s", 'info'); } if(is_array($data)) { echo("<script>$msg_type('".implode(', ', $data)."');</script>"); } else { echo("<script>$msg_type('".$data."');</script>"); } } public static function info($data) { self::write($data); } public static function error($data) { self::write($data, 'error'); } public static function log($data) { self::write($data, 'log'); } public static function warn($data) { self::write($data, 'warn'); } } ?>
代码如下:
<?php require_once('WebConsole.php'); $fruits = array('apple', 'mange', 'banana'); WebConsole::log($fruits); WebConsole::info($fruits); WebConsole::warn($fruits); WebConsole::error($fruits); ?>
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh