What are differences between location and refresh in codeginiter redirect function?

前端 未结 2 924
Happy的楠姐
Happy的楠姐 2021-02-09 07:25

I would like to know what are differences between location and referesh in Codeigniter redirect() function?

https://www.

2条回答
  •  深忆病人
    2021-02-09 07:51

    Codeigniter redirect method:

    /**
     * Header Redirect
     *
     * Header redirect in two flavors
     * For very fine grained control over headers, you could use the Output
     * Library's set_header() function.
     *
     * @access  public
     * @param   string  the URL
     * @param   string  the method: location or redirect
     * @return  string
     */
    if ( ! function_exists('redirect'))
    {
        function redirect($uri = '', $method = 'location', $http_response_code = 302)
        {
            if ( ! preg_match('#^https?://#i', $uri))
            {
                $uri = site_url($uri);
            }
    
            switch($method)
            {
                case 'refresh'  : header("Refresh:0;url=".$uri);
                    break;
                default         : header("Location: ".$uri, TRUE, $http_response_code);
                    break;
            }
            exit;
        }
    }
    

    PHP header

    http://php.net/manual/en/function.header.php

提交回复
热议问题