I'm testing setting environment variables in .htaccess for my php code to use, and facing strange behaviour from the getenv() function.
In my .htaccess, I set
SetEnv BOP 23
And in my php, I successfully get
$res = getenv("BOP");
echo($res);
>>>> 23
But when I try to var_dump(getenv()); or use debugger to see what is in the array returned by getenv(), I get an array of length 23 BUT my "BOP" variable is missing.
For example, if I try to dump getenv() into an array and make a lookup:
$array = getenv();
echo($array["BOP"])
I get an exception:
Exception has occurred.
Notice: Undefined index: BOP
From what I read here about getenv() https://www.php.net/manual/en/function.getenv.php
... If
varnameis omitted, all environment variables are returned as associative array.
So what am I missing? Why can I access my variable but isn't it in getenv()?