I would like to send the HEAD command of the Hypertext Transfer Protocol to a server in PHP to retrieve the header, but not the content or a URL. How do I do this in an efficient way?
The probably most common use-case is to check for dead web links. For this I only need the reply code of the HTTP request and not the page content.
Getting web pages in PHP can be done easily using file_get_contents("http://...")
, but for the purpose of checking links, this is really inefficient as it downloads the whole page content / image / whatever.