【问题标题】:passing get variables without opening URL [duplicate]在不打开 URL 的情况下传递获取变量 [重复]
【发布时间】:2012-11-09 09:51:10
【问题描述】:

可能重复:
How to read a web page in PHP

我确信有一些简单的方法可以做到这一点。我需要将 get 变量传递给我的购物车软件以记录转换,但不重定向用户,我只希望服务器将 GET 变量发送到 URL。我宁愿不要在 php.ini 中打开 allow_url_fopen 。

有人知道最好的方法吗?提前致谢。

【问题讨论】:

标签: php


【解决方案1】:

服务器端,您最好的选择可能是使用cURL - 详情请参阅文档,使用起来并不难。

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://www.example.com/script.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

curl_close($ch);

if ($response === false) {
    // Failed to connect or some error occurred
} else {
    // Everything was fine, check the response here if you need to
}

【讨论】:

    猜你喜欢
    • 2013-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    • 2021-03-29
    • 1970-01-01
    • 2017-01-28
    相关资源
    最近更新 更多