Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: difference between getenv() and apache_getenv()

I'm using an Apache 2 server and hosting a web app there. I'm setting some environment variables in my vhost by using the Apache SetEnv VARIABLE value command.

When looking to retrieve the value in PHP, I've some across two methods. getenv() and apache_getenv().

Is there any real difference? Is there a reason to prefer one over the other? Not sure what the point of have the apache_getenv() method is if getenv() works the same and allows your code to be server agnostic.

like image 482
Matthew Herbst Avatar asked Feb 08 '23 04:02

Matthew Herbst


1 Answers

getenv calls apache_getenv if you're running the Apache SAPI, otherwise it asks the system. So, no, there is no real functional difference. Stick with getenv.

like image 133
bishop Avatar answered Feb 10 '23 23:02

bishop