Forum Moderators: coopster

Message Too Old, No Replies

HTTP Header Response

Get header response with php

         

dermotirl

12:04 pm on Oct 11, 2006 (gmt 0)

10+ Year Member



Hi

Is the anyway to get the header response of a url/site with php, I would like to be able to enter a url and get the response code e.g. 200.

Any help would be greatly appreciated.

dermotirl

12:34 pm on Oct 11, 2006 (gmt 0)

10+ Year Member



I got it working, I used the php function get_headers -- Fetches all the headers sent by the server in response to a HTTP request.

Note it only works as of PHP 5.1.3

spinnercee

12:34 pm on Oct 11, 2006 (gmt 0)

10+ Year Member



You can send a HEAD or GET request -- if the server allows the HEAD method, it will only return the headers for the request.

with PHP you should use fsockopen()/fputs()/fread()/fclose() for that... you cannot use fopen(URL) because that will only return the request body.

Psychopsia

2:50 pm on Oct 11, 2006 (gmt 0)

10+ Year Member



Also you can use apache_request_headers [php.net]()

It works in PHP 4.3 > 5