<?php
$req_headers = getallheaders();                            //get all request headers

foreach ($req_headers as $name => $value)                  //loop thru all request headers 
{
    if (substr($name,0,6) == 'custom')                     //if it starts with 'custom'
    {
        $name_value = $name .": ". $value;                 //get the custom request header  
        header($name_value);                               //add it to the response headers
    }                              
}

header("custom-resp-header-id:  123");                    //add 2 additional response headers
header("custom-resp-header-sex: Male");
?>    


<html>
<body>
<!---------------------------------------------------------------->
<?php
print "<h2>Request Headers Received by Server...</h2>";

$req_headers = getallheaders();                            //get all request headers

foreach ($req_headers as $name => $value)                  //loop thru all request headers  
    print "<b>$name:</b> $value <br>";                     //print it on the web page


//-----------------------------------------------------------------

print "<h2>Response Headers Sent by Server...</h2>";
print "<h3>Added 2 custom response headers</h3>";

$resp_headers = headers_list();                           //get response headers

sort($resp_headers);
 
foreach ($resp_headers as $name_value)                    //loop thru all response headers 
{
    $array = explode(": ", $name_value);   
    echo "<b>$array[0]:</b> $array[1] <br>";              //print it on the web page
}
?>
<!----------------------------------------------------------------->
</body>
</html>