How to get info on sent PHP curl request

To get information about a cURL request that you have sent using PHP, you can use the curl_getinfo() function. This function takes a cURL resource as an argument and returns an associative array of information about the request.

Watch a course Learn object oriented PHP

Here is an example of how to use curl_getinfo():

<?php

// Create a cURL resource
$ch = curl_init();

// Set the URL that you want to send the request to
curl_setopt($ch, CURLOPT_URL, "https://www.example.com");

// Set other options for the request
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Send the request
$response = curl_exec($ch);

// Get information about the request
$info = curl_getinfo($ch);

// Print the information
print_r($info);

// Close the cURL resource
curl_close($ch);

?>

This will print an associative array containing information about the request, such as the HTTP status code, the content type, the size of the response, and more.