且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP Curl发布数据并检索响应?

更新时间:2023-02-24 13:55:22

您必须将CURLOPT_RETURNTRANSFER选项设置为true。

You'll have to set the CURLOPT_RETURNTRANSFER option to true.

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);

curl_close($ch);

对您的请求的响应将在$ result变量中提供。

The response to your request will be available in the $result variable.