0

I had the same problem as these fine folks: Why is my $_ENV empty?

However, after adding 'E' to the variables_order in /etc/php.ini the problem persists. I've restarted my apache server and the result from the 'php -i' command include: 'variables_order => EGPCS => EGPCS'. Still my $_ENV is empty when I try to access it in my php script. Any ideas?

I'm running on OS X 10.6.8, php 5.3.15, apache 2.2.22

Actually, I see it is not entirely empty since var_dump(); returns: "{ ["PATH"]=> string(29) "/usr/bin:/bin:/usr/sbin:/sbin" }"

Addition:

Running phpinfo() in my script reveals the following:

Configuration File (php.ini) Path:   /etc
Loaded Configuration File:           /private/etc/php.ini

If I open /private/etc/php.ini in a browser I open a file where 'E' is included in the variables_order

Community
  • 1
  • 1
Thrasi
  • 418
  • 1
  • 5
  • 15
  • FWIW, `getenv()` does tend to work more reliably here. Note however, that you _cli_ PHP might use another config file then your _webservers_ PHP, best check with good ol' `phpinfo` whether it's also set for your webserver. – Wrikken Sep 12 '13 at 18:15
  • I can use getenv to access specific variables right? However, I am trying to loop through all my environment variables without knowing which ones are set at the time. Unless there is another way, I think I need them all in an array. @Wrikken Would you check out my results from using phpinfo()? – Thrasi Sep 12 '13 at 22:35
  • Well, if the `E` is there, it is all you can do. However, what kind of PHP are you running, module, cgi? Does switching to the other make a difference? How do you _set_ the environmental variables you're looking for? – Wrikken Sep 13 '13 at 06:08
  • well, I'm new to php. I'm not sure what kind I'm running. What I do is I start an apache server, place my php script in ~/Sites in my mac and I open the script in chrome. I'm not aware of setting the environmental variables, at least not conscientiously in the php script. I'm not looking for specific variables but just all available e.g. REMOTE_ADDR, PATH, REQUEST_URL, HTTP_HOST etc. – Thrasi Sep 14 '13 at 19:17
  • That would be the `$_SERVER` array, not the `$_ENV` one... – Wrikken Sep 14 '13 at 19:39

0 Answers0