为什么在调用CURL之后标头功能不起作用? [英] Why the header function is not working after CURL call?

查看:95
本文介绍了为什么在调用CURL之后标头功能不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是使用CURL对URL的调用:

Following is the call to an URL using CURL :

<?php
    ini_set('display_startup_errors',1);
    ini_set('display_errors',1);
    error_reporting(-1);

    $link = $_GET['link'];
    $url  = "http://www.complexknot.com/user/verify/link_".$link."/";


    // create a new cURL resource
    $ch = curl_init();

    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // grab URL and pass it to the browser
    curl_exec($ch);

    // close cURL resource, and free up system resources
    curl_close($ch);
?>

变量 $ url 包含一个URL我正在使用CURL。

The variable $url contains one URL which I'm hitting using CURL.

文件中写入的逻辑(存在于变量 $ url 中)是

The logic written in the file(present in a variable $url) is working absolutely fine.

执行代码后,我希望将控件重定向到一个URL。为此,我编写了以下代码:

After executing the code I want the control to be redirected to one URL. For it I've written following code :

header('Location: http://www.complexknot.com/login.php');
exit; 

以下代码不起作用。 URL http://www.complexknot.com/login.php 没有打开,并且出现空白页。这就是我面临的问题。

The following code is not working. The URL http://www.complexknot.com/login.php is not opening and a blank white page appears. This is the issue I'm facing.

如果我不使用CURL并点击URL,即 $ url 中包含的URL,它将得到重定向到URL http://www.complexknot.com/login.php ,这意味着当我在浏览器中单击URL时标头功能可以正常工作。

If I don't use the CURL and hit the URL i.e. the URL contained in $url then it gets redirect to the URL http://www.complexknot.com/login.php that means header function works fine when I hit the URL in browser.

为什么我从CURL调用它时不起作用?

Why it's not working when I call it from CURL?

请有人帮助我。

谢谢。

推荐答案

您可以使用

<?php echo< script> window.location.href ='http://www.complexknot.com/login.php';</script>\";die; ?>

这篇关于为什么在调用CURL之后标头功能不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆