$value) { echo "$key:$value
"; }; } /** * 判断请求协议是否为https * @return bool */ function is_https() { if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { return TRUE; } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { return TRUE; } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { return TRUE; } return FALSE; } /** * 异常处理 * @param $error_level * @param $error_str * @throws Exception */ function err_handler($error_level, $error_str) { throw new Exception("[$error_level] $error_str", 100001); } /** * 判断session是否已开启 * @return bool */ function is_session_started() { return function_exists('session_status') ? (PHP_SESSION_ACTIVE == session_status()) : (!empty (session_id())); } ?>