本文介绍了getenv()与$ _ENV在PHP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

code> getenv()和 $ _ ENV 之间有什么区别?

What is the difference between getenv() and $_ENV?

使用两者之间的任何折中?

Any trade-offs between using either?

我注意到有时 getenv()给了我而$ $ _ ENV 不(例如 HOME )。

I noticed sometimes getenv() gives me what I need, while $_ENV does not (such as HOME).

推荐答案

根据关于getenv的php文档,它们完全一样,除了 getenv 将以不区分大小写的方式寻找变量。大部分时间可能并不重要,但其中一个对文档的评论就解释了:

According to the php documentation about getenv, they are exactly the same, except that getenv will look for the variable in a case-insensitive manner. Most of the time it probably doesn't matter, but one of the comments on the documentation explains:

因为这样,我可能会选择使用 getenv ,除非您确定要尝试检索的变量的标题。

Because of that, I would probably opt to use getenv unless you are certain about the casing of the title of the variable you are trying to retrieve.

这篇关于getenv()与$ _ENV在PHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 15:08