• 自定义跳转函数


    /**
     * URL跳转
     * @param string $url 跳转地址
     * @param int $time 跳转延时(单位:秒)
     * @param string $msg 提示语
     */
    function redirect($url, $time = 0, $msg = '') {
        $url = str_replace(array("
    ", "
    "), '', $url); // 多行URL地址支持
        if (empty($msg)) {
            $msg = "系统将在 {$time}秒 之后自动跳转到 {$url} !";
        }
        if (headers_sent()) {
            $str = "<meta http-equiv='Refresh' content='{$time};URL={$url}'>";
            if ($time != 0) {
                $str .= $msg;
            }
            exit($str);
        } else {
            if (0 === $time) {
                header("Location: " . $url);
            } else {
                header("Content-type: text/html; charset=utf-8");
                header("refresh:{$time};url={$url}");
                echo($msg);
            }
            exit();
        }
    }
    /**
     * URL跳转
     * @param string $url 跳转地址
     * @param int $time 跳转延时(单位:秒)
     * @param string $msg 提示语
     */
    function redirect($url, $time = 0, $msg = '') {
    	$url = str_replace(array("
    ", "
    "), '', $url); // 多行URL地址支持
    	if (empty($msg)) {
    		$msg = "系统将在 {$time}秒 之后自动跳转到 {$url} !";
    	}
    	if (headers_sent()) {
    		$str = "<meta http-equiv='Refresh' content='{$time};URL={$url}'>";
    		if ($time != 0) {
    			$str .= $msg;
    		}
    		exit($str);
    	} else {
    		if (0 === $time) {
    			header("Location: " . $url);
    		} else {
    			header("Content-type: text/html; charset=utf-8");
    			header("refresh:{$time};url={$url}");
    			echo($msg);
    		}
    		exit();
    	}
    }
  • 相关阅读:
    poj 3258
    CodeForces 367E Sereja and Intervals
    Codeforces Round #240 (Div. 2) C Mashmokh and Numbers
    Codeforces Round #240 (Div. 2) D
    zoj 3768 Continuous Login
    2014/4/4做题感悟
    HDU 1878 欧拉回路
    HDU 3018 Ant Trip
    POJ 3694 Network
    Codeforces Round #239 (Div. 2)
  • 原文地址:https://www.cnblogs.com/blueskycc/p/5363999.html
Copyright © 2020-2023  润新知