LMSouq
php-dev Open

Can PHP cURL retrieve response headers AND body in a single request?

GR
gremo
1 month ago
3 views
Problem Description
Is there any way to get both headers and body for a cURL request using PHP? I found that this option: curl_setopt($ch, CURLOPT_HEADER, true); is going to return the **body plus headers**, but then I need to parse it to get the body. Is there any way to get both in a more usable (and secure) way? Note that for "single request" I mean avoiding issuing a HEAD request prior of GET/POST.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base