0

I've got a simple curl statement that is running from bash that sends a header to a Apache2 server running PHP.

curl -H "myheader: test" https://example.com/listener.php

The listener.php file contains:

<?php
$myheader = $_SERVER['myheader'];
echo $myheader;
?>

The header is not being printed and instead I get in the apache logs: PHP Notice: Undefined index: myheader in /var/www/listener.php

I must be missing something simple but can't figure out what.

Greg
  • 1,715
  • 5
  • 27
  • 36
  • 1
    Custom HTTP headers (which should not use a name like the one you are using, btw.) will be put into $_SERVER prefixed with `HTTP_`; https://www.php.net/manual/en/reserved.variables.server.php#87195 – CBroe Feb 27 '23 at 13:19

0 Answers0