简体   繁体   English

PHP:getenv()和apache_getenv()之间的区别

[英]PHP: difference between getenv() and apache_getenv()

I'm using an Apache 2 server and hosting a web app there. 我正在使用Apache 2服务器并在那里托管Web应用程序。 I'm setting some environment variables in my vhost by using the Apache SetEnv VARIABLE value command. 我正在使用Apache SetEnv VARIABLE value命令在我的vhost中设置一些环境变量。

When looking to retrieve the value in PHP, I've some across two methods. 当想要在PHP中检索值时,我有两种方法。 getenv() and apache_getenv() . getenv()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. 如果getenv()工作方式相同并且允许您的代码与服务器无关,那么apache_getenv()方法的apache_getenv()是什么。

getenv calls apache_getenv if you're running the Apache SAPI, otherwise it asks the system. 如果您正在运行Apache SAPI, getenv 调用 apache_getenv ,否则会询问系统。 So, no, there is no real functional difference. 所以,不,没有真正的功能差异。 Stick with getenv . 坚持getenv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM