• <i id='QIXxl'><tr id='QIXxl'><dt id='QIXxl'><q id='QIXxl'><span id='QIXxl'><b id='QIXxl'><form id='QIXxl'><ins id='QIXxl'></ins><ul id='QIXxl'></ul><sub id='QIXxl'></sub></form><legend id='QIXxl'></legend><bdo id='QIXxl'><pre id='QIXxl'><center id='QIXxl'></center></pre></bdo></b><th id='QIXxl'></th></span></q></dt></tr></i><div id='QIXxl'><tfoot id='QIXxl'></tfoot><dl id='QIXxl'><fieldset id='QIXxl'></fieldset></dl></div>
    <tfoot id='QIXxl'></tfoot>
      • <bdo id='QIXxl'></bdo><ul id='QIXxl'></ul>
        <legend id='QIXxl'><style id='QIXxl'><dir id='QIXxl'><q id='QIXxl'></q></dir></style></legend>

        <small id='QIXxl'></small><noframes id='QIXxl'>

        PHP 中的 getenv() 与 $_ENV

        时间:2024-08-10
          <bdo id='4Qubv'></bdo><ul id='4Qubv'></ul>
        • <tfoot id='4Qubv'></tfoot>
            <tbody id='4Qubv'></tbody>
          <i id='4Qubv'><tr id='4Qubv'><dt id='4Qubv'><q id='4Qubv'><span id='4Qubv'><b id='4Qubv'><form id='4Qubv'><ins id='4Qubv'></ins><ul id='4Qubv'></ul><sub id='4Qubv'></sub></form><legend id='4Qubv'></legend><bdo id='4Qubv'><pre id='4Qubv'><center id='4Qubv'></center></pre></bdo></b><th id='4Qubv'></th></span></q></dt></tr></i><div id='4Qubv'><tfoot id='4Qubv'></tfoot><dl id='4Qubv'><fieldset id='4Qubv'></fieldset></dl></div>

              • <small id='4Qubv'></small><noframes id='4Qubv'>

                  <legend id='4Qubv'><style id='4Qubv'><dir id='4Qubv'><q id='4Qubv'></q></dir></style></legend>
                  本文介绍了PHP 中的 getenv() 与 $_ENV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  getenv()$_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).

                  推荐答案

                  根据php关于 getenv 的文档,它们完全相同,只是 getenv 在不区分大小写的文件系统(如 Windows)上运行时会以不区分大小写的方式查找变量.在 Linux 主机上,它仍然区分大小写.大多数时候这可能无关紧要,但文档中的一条评论解释道:

                  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 when running on case-insensitive file systems (like Windows). On Linux hosts it still works as case-sensitive. Most of the time it probably doesn't matter, but one of the comments on the documentation explains:

                  例如在 Windows 上 $_SERVER['Path'] 就像你看到的那样,第一个字母大写,而不是你可能期望的 'PATH'.

                  For example on Windows $_SERVER['Path'] is like you see, with the first letter capitalized, not 'PATH' as you might expect.

                  因此,我可能会选择使用 getenv 来改善跨平台行为,除非您确定要检索的环境变量的大小写.

                  Because of that, I would probably opt to use getenv to improve cross-platform behavior, unless you are certain about the casing of the environment variable you are trying to retrieve.

                  Steve Clay 在此答案中的评论突出了另一个区别:

                  Steve Clay's comment in this answer highlights another difference:

                  新增getenv() 优点:访问前无需检查isset/empty.getenv() 不会发出通知.

                  Added getenv() advantage: you don't need to check isset/empty before access. getenv() won't emit notices.

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

                  上一篇:如何为 PHP 设置全局环境变量 下一篇:如何在 Laravel whoops 输出中隐藏 .env 密码?

                  相关文章

                    1. <tfoot id='UgzdV'></tfoot>
                      • <bdo id='UgzdV'></bdo><ul id='UgzdV'></ul>

                      <small id='UgzdV'></small><noframes id='UgzdV'>

                    2. <i id='UgzdV'><tr id='UgzdV'><dt id='UgzdV'><q id='UgzdV'><span id='UgzdV'><b id='UgzdV'><form id='UgzdV'><ins id='UgzdV'></ins><ul id='UgzdV'></ul><sub id='UgzdV'></sub></form><legend id='UgzdV'></legend><bdo id='UgzdV'><pre id='UgzdV'><center id='UgzdV'></center></pre></bdo></b><th id='UgzdV'></th></span></q></dt></tr></i><div id='UgzdV'><tfoot id='UgzdV'></tfoot><dl id='UgzdV'><fieldset id='UgzdV'></fieldset></dl></div>
                      <legend id='UgzdV'><style id='UgzdV'><dir id='UgzdV'><q id='UgzdV'></q></dir></style></legend>