PHP中如何发送GET请求
来源:互联网
时间:2025-11-07 19:38:20
浏览量: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;
上一篇:组装电脑配置单及报价清单
下一篇:在计算机中1kb等于多少字节