How can one use get_headers() function in PHP to check headers?

To check headers in PHP, you can use the get_headers() function, which retrieves headers from a given URL. This can be useful for checking the response headers of a website or API endpoint. You can use get_headers() to get an array of headers and then loop through them to display or analyze the information.

$url = 'https://www.example.com';
$headers = get_headers($url);

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