zoukankan      html  css  js  c++  java
  • 自定义跳转函数

    /**
     * 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();
    	}
    }
  • 相关阅读:
    简易四则运算
    对GitHub的认识
    对‘前辈’们的博文有感
    javascript中的JSON序列化与反序列化
    初步体验javascript try catch机制
    JQuery拾遗
    直面Javascript面试题算法思路
    ECMAScript5下Array的方法
    浅谈javascript中的数据类型和引用类型
    ECMAScript 5.1中对属性的操作
  • 原文地址:https://www.cnblogs.com/blueskycc/p/5363999.html
Copyright © 2011-2022 走看看