The php Function Get_Headers
PHP is a server-side scripting language created with web development in mind. It is free and open source, and it allows developers to create dynamic websites. It is written in a procedural style and uses a scalar variable to hold the information being processed by a program. It has a large set of libraries that provide the functionality required for developing web applications.
The php function get_headers is used to read HTTP request headers from the $_SERVER array. The optional format parameter determines whether the headers should be returned as an associative or indexed array. If the format is set to None, the associative array will return a list of headers; if the format is set to any non-zero value, the headers will be parsed and returned as an indexed array. The return value is an indexed or associative array with the headers, or false on failure.
In addition, if the URL is being redirected, this function will display a Warning on failure to fetch the headers. This is not a bug; it is simply how the function behaves when it encounters a redirect. For this reason, it is recommended to use the cURL functions if you need to fetch the headers for a redirecting URL.
Another thing to keep in mind is that if the $replacement and/or $http_response_code parameters are set, the return will include only those headers whose values match those parameters. For example, if you are redirecting to the same URL using two different 'Location' headers (note that the uppercase L is important), this function will return an associative array with both of these.