Forum Moderators: coopster

Message Too Old, No Replies

Access to the php header when it arrives.

Access php header

         

tommytx

5:08 pm on Jul 19, 2006 (gmt 0)

10+ Year Member



Can anyone help me with the php code to grab the headers.
I want to be able to see what is in the header when it arrives.
Is this something php can do for me?

When an html file is requested the server sends a header to the browser to tell it to get ready and here is what I expect to send you.

I want to be able to capture the header from the server.

I have tried
************
<?php
foreach ($header as $a( {
print $a;
}
?>

to no avail.
Lets saythe php page send this header every time someone accesses it. I want to capture this header info or view it when it arrives.

An example of someone sending headers via php. I want to view them when they arrive.

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

Now to be specific as to what I am doing, is I have an auto ping system for blogs. I can enter a ping url and and the url I want to ping and a site title and it will send a ping.

I assume that if I enter a ping url that goes to my site lets say [mysite.com...]

The program will format it correctly and place the url and title in the header and send it to mysite vice a real ping site.

If I can see the header when it arrives at test.php I should be able to see the url it sent an also the title and or description of the site.

I want use that received info to send an ok back to the program to say you were successful. That way I can do some testing without aggravating the real ping people out there.

They might ban me if I hit the for test purposes.

Sekka

7:13 pm on Jul 19, 2006 (gmt 0)

10+ Year Member



I don't know much about headers, but as far as I am aware the headers are set as the PHP is being run, not before, so can't "grab them".

You can set them yourself, so you have as much control as you need, but there is essentially nothing to grab.

I may be way off, but this is my understanding.

whoisgregg

7:23 pm on Jul 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think tommytx wants the browser request headers, not the server response headers.

I don't know how to access that from PHP. Sure, a lot of what is sent in the request header is parsed into the $_SERVER superglobal, so check out the PHP manual on reserved variables [us3.php.net] to see if you can find what you need. But the raw request header? Dunno about that.