How can one request only the header of a file from a remote HTTP server in PHP?

When requesting only the header of a file from a remote HTTP server in PHP, you can use the `get_headers()` function. This function sends a HEAD request to the specified URL and returns an array of headers. By using this function, you can retrieve only the header information without downloading the entire file.

$url = 'http://example.com/file.txt';
$headers = get_headers($url);

foreach ($headers as $header) {
    echo $header . "<br>";
}