Is there a way to gather the HTTP header send from a server so that I can check if it is a code 200 or a code 404 and base the output from that.

Thanks for the help

EmcLinux

Recommended Answers

All 2 Replies

if you use straightforwad php :
get_headers()

I like cUrl better
after executing,
you can retrieve the headers from the instance with curl_getinfo()
...

$curl_info = curl_getinfo($ch);
foreach($curl_info as $key=>$value) {
echo $key .'='. $value.'<br />';
}

...
or

$curl_info = curl_getinfo($ch);
echo $curl_info['http_code'];

get_headers() was exactly what I was looking for thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.