【问题标题】:How can send request server and receive response by php如何通过php发送请求服务器并接收响应
【发布时间】:2024-01-07 23:25:01
【问题描述】:

【问题讨论】:

  • 我不知道你在这里的真正意思......但我猜你正在寻找 CURL......
  • 使用 CURL。这可能是你想要的。
  • 请求是this,响应是that,但问题是Unknown
  • 问题非常抽象,含糊不清。

标签: php codeigniter httprequest


【解决方案1】:

根据您的帖子,我的理解是您想要 php 中 curl 示例的代码。以下代码将使用 curl 发出 HTTP 请求并在 $content 中返回响应。

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,'http://www.anydomain.com/anyapi.php?a=parameters');
$content = curl_exec($ch);
echo $content;
?>

希望这将有助于为您的问题提供更多信息,以便我可以帮助您。

【讨论】: