How to capture HTTP Response headers of the same page using PHP

Hi All, I have a requirement of displaying HTTP Response headers in the same page being redered using PHP.
This is to track various responses sent by the Apache Server for same page on different scenarios (like 200, 304, 503)

I have a single php file as follows:

——-index.php——————————————————————
<?php
header(‘Cache-Control: no-cache’);
print(‘<?xml version=”1.0″ encoding=”ISO-8859-1″?>’.”\n”);
?>
<!DOCTYPE html PUBLIC “-//WAPFORUM//DTD XHTML Mobile 1.0//EN” “http://www.wapforum.org/DTD/xhtml-mobile10.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>

<head><title>Test</title>
<link type=”text/css” rel=”stylesheet” href=”mycss.css”/>
</head>

<body>
<p>This page contains the header ‘Cache-Control: no-cache’<br/>
<?php echo date(“F j, Y, g:i:s a”); ?><br/>

</body>
</html>
—–end of index.php——————————————————————–

This page has a header “Cache-Control”. If this page is retrieved from the local Cache then 304 may be received. If Origin server sends then may be 200, if Origin server is unable to render then may be 503 received. Whereas it is required to capture these response headers in the same page and display.

What code can be added to include the Status code and Status text to get displayed. I have Apache/v1.3.27 on Linux with PHP 4.4.8

Comments are closed.

MF-Soft-Ex © 2004-2010 All Rights Reserved. Using WordPress Engine
Custom Software and Web Application Development Blog