0

I am trying to extract value form an incoming request's header and then echo it back to the client, but this code doesn't seem to work.

<?php 

$custom_header = $_SERVER['X-Forwarded-Host'];

echo "$custom_header";

?>

I am passing X-Forwarded-Host: google.com as a header in the request and ideally I should get the response google.com but the error that I get is Undefined index: X-Forwarded-Host in C:\xampp\htdocs\reflect.php

I'm running this script on my local machine using XAMPP.

Akash
  • 1

1 Answers1

2

php convert custom headers as HTTP_X_FORWARDED_HOST

    $custom_header = $_SERVER['HTTP_X_FORWARDED_HOST'];
SiZE
  • 2,217
  • 1
  • 13
  • 24