How to properly use CURL_INIT for a GET request? or Why is my CURL_INIT GET request not working as ex

16 Replies, 1052 Views

CURL_INIT GET requests are like ordering pizza—you ask (request), they deliver (response). Here’s the simplest way:

```php
$curl = curl_init("https://httpbin.org/get");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curl);
curl_close($curl);
print_r($output);
```

RETURNTRANSFER is like asking for the pizza to be handed to you instead of thrown at your face. Necessary? Yes, unless you like messy code.

For debugging, check out `curl_error()` if things go sideways.

Messages In This Thread



Users browsing this thread: 1 Guest(s)