PHP发送GET请求的方法有以下几种:
$response = file_get_contents('http://example.com/api?param1=value1¶m2=value2');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/api?param1=value1¶m2=value2');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$client = new \http\Client;
$request = new \http\Client\Request('GET', 'http://example.com/api?param1=value1¶m2=value2');
$client->enqueue($request)->send();
$response = $client->getResponse()->getBody();
这些方法都可以用来发送GET请求,选择哪种方法取决于个人的需求和偏好。