I am do some curl process, some site must set CURLOPT_HEADER, true, so that could get the html code.
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $url);
curl_setopt($ch2, CURLOPT_HEADER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch2);
curl_close($ch2);
echo $html;
the return data like:
HTTP/1.0 200 OK Date: Wed, 14 Nov 2012 17:58:26 GMT Expires: Wed, 14 Nov 2012 18:08:26 GMT Cache-Control: max-age=600...
<html...
So how to remove some data before <html>(The CURLOPT_HEADER return data: HTTP/1.0 200 OK…)?
CURLOPT_HEADERdoes not affect what the site returns to you. You can remove it and if you get empty content back – then something else is wrong.CURLOPT_HEADERis just for your convenience so you can see what the server said back to your script. Some web API’s pass data in the headers and this allows you to access it.You can split the content from the header like this