Jump to content

[SOLVED] Using String As CURLOPT Setting - Painful!


Dave3765

Recommended Posts

<?php
$url = 'http://www.google.com';
$opt = 'CURLOPT_NOBODY';
$val = 1;
$html = get($url, $opt, $val);
echo $html;

function get($url, $opt, $val) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HEADER, 1); 
curl_setopt($curl, $opt, $val); // This is not working
$html = curl_exec($curl);
curl_close($curl);
return $html;
}
?>

 

The above example code does show that body of the request - even though I thought I had set CURLOPT_NOBODY.

 

When CURLOPT's or flags are strings it seems to fail.

 

In this case there is no error - just not the desired result.

 

Can anyone tell me where I'm going wrong?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.