I have index.php running on WAMP and all I want to do is return 200 Ok header. I have:
echo "Index3<br />";
//All I need to do is execute a method.
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
echo "Serving " .$request_method;
//And send back a response header.
header('HTTP/1.1 200 Ok');
foreach (getallheaders() as $name => $value) {
echo "$name: $value\n<br />";
}
I see nothing in Firebug(in both the Console and Net tab). In the foreach I see all headers about Accept, Connect, Cache etc. but no 200? I only get something in the Console when I change to a 400 response in the code above, why?
The headers must be the first thing sent to the browser. You have
echostatements before yourheader. You cannot do this.Also, the
HTTP/1.1 200 OKis not considered a “header” likeAccept,Cacheare. It will generally be available under somestatusCodeproperty. Firebug should show it in the “Network” tab. It will be listed next to each request.