Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的函数redirect()是什么_Php_Codeigniter - Fatal编程技术网

php中的函数redirect()是什么

php中的函数redirect()是什么,php,codeigniter,Php,Codeigniter,我使用一个代码连接gmail并获取我的好友列表。在该代码中有一个函数调用 redirect('https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token='. $oauth->rfc3986_decode($accrss_token['oauth_token']), 'location'); 我搜索了函数redirect(),但在php手册中没有找到它。它是php中的内置函数吗 第二个参数是'location'该参数的用

我使用一个代码连接gmail并获取我的好友列表。在该代码中有一个函数调用

redirect('https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token='. $oauth->rfc3986_decode($accrss_token['oauth_token']), 'location');
我搜索了函数
redirect()
,但在php手册中没有找到它。它是php中的内置函数吗

第二个参数是
'location'
该参数的用途是什么

下面是使用它的函数:

public function connect_google($oauth=null){

if(!$oauth)
{
    return null;
}
//create a gmailcontacts objects
$getcontact = new GmailGetContacts();
$accrss_token = $getcontact->get_request_token($oauth, false, true, true);

$this->ci->session->set_userdata('oauth_token', $accrss_token['oauth_token']);
$this->ci->session->set_userdata('oauth_token_secret', $accrss_token['oauth_token_secret']);
//redirect to google auth
redirect('https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token='. $oauth->rfc3986_decode($accrss_token['oauth_token']), 'location');

}
使用
标题


正如你所说,它不是一个内置函数,所以我们不知道它应该是什么样子。 然而,考虑到名字,我想它应该是这样的:

function redirect($url, $header)
{
 header("$header: $url");
}

因为发送
位置:{ur}
标题会将您的页面重定向到另一个。

这可能是一个用户定义的函数。它可能与名称一起工作,第一个参数是重定向到的页面,第二个参数是告诉函数它确实是重定向到
位置的。只需查看header函数

它是CodeIgniter URL帮助程序的一部分。见:

从文件中:

是否将“头重定向”到指定的URI。如果您指定将生成的链接的完整站点URL,但对于本地链接,只需向您要定向的控制器提供URI段即可创建链接。该函数将基于您的配置文件值构建URL


我原以为在设置标题后,该函数将包括
exit
die
。可能还包括检查是否已经发送了头等,以改进错误处理。
function redirect($url, $header)
{
 header("$header: $url");
}