How to save cURL output to string

PHP Logo

You can save the cURL output as a string for further manipulation.

Following code takes care of:

// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "");
// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// save output to string
$output = curl_exec($ch);
// close curl resource to free up system resources

1 thought on “How to save cURL output to string”

Leave a Reply

Your email address will not be published. Required fields are marked *