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.

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


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

// Set the URL that you want to send the request to
curl_setopt($ch, CURLOPT_URL, "");

// 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

// Close the cURL resource


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.