php 封装好得url 跳转

180it 2021-02-28 PM 1472℃ 0条
/**
 * url 跳转
 * @param  $url   跳转的url
 * @param  $type  跳转类型 301 404 
 * @param  $tip   提示信息
 */
function redirect($url = '/', $type = '', $tip = '') {
    if ($type == '301') {
        Header('HTTP/1.1 301 Moved Permanently'); 
    } elseif ($type == '404') {
        Header('HTTP/1.1 404 Not Found'); 
        echo file_get_contents($url);
    } else {
        if ($tip) {
            Header('Content-type:text/html;charset=utf-8'); 
            echo '<script>alert("' . addslashes($tip) . '");location.href="' . $url . '";</script>';
        } else {
            echo '<script>location.href="' . $url . '";</script>';
        }
    }
    exit();
}

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

php 封装好得url 跳转