Here’s a simple example of a CURL_INIT GET request in PHP. This hits a dummy API and returns the response.
```php
$ch = curl_init("https://jsonplaceholder.typicode.com/posts/1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
```
CURLOPT_RETURNTRANSFER is *kinda* necessary—without it, curl_exec() just dumps the output instead of storing it in a variable. If you wanna process the response, you need it.
For testing, Postman or Insomnia are great tools to mock requests before coding.
```php
$ch = curl_init("https://jsonplaceholder.typicode.com/posts/1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
```
CURLOPT_RETURNTRANSFER is *kinda* necessary—without it, curl_exec() just dumps the output instead of storing it in a variable. If you wanna process the response, you need it.
For testing, Postman or Insomnia are great tools to mock requests before coding.
