首页互联网 正文

PHP中如何发送GET请求

2024-02-19 9 0条评论

在PHP中发送GET请求可以使用file_get_contents()函数或者cURL扩展库。

使用file_get_contents()函数:

$url = 'http://example.com/api/users'; $response = file_get_contents($url); echo $response; 

使用cURL扩展库:

$url = 'http://example.com/api/users'; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); curl_close($curl); echo $response; 

TAG:美国免费php空间

文章版权及转载声明

本文作者:admin 网址:http://news.edns.com/post/53942.html 发布于 2024-02-19
文章转载或复制请以超链接形式并注明出处。

取消
微信二维码
微信二维码
支付宝二维码