php $_env 空,php – 为什么我的$_ENV为空?

原来有两个问题:

$ _ENV只填充如果php.ini允许它,它似乎没有做默认情况下,至少不是在默认WAMP server安装。

; This directive determines which super global arrays are registered when PHP

; starts up. If the register_globals directive is enabled, it also determines

; what order variables are populated into the global space. G,P,C,E & S are

; abbreviations for the following respective super globals: GET, POST, COOKIE,

; ENV and SERVER. There is a performance penalty paid for the registration of

; these arrays and because ENV is not as commonly used as the others, ENV is

; is not recommended on productions servers. You can still get access to

; the environment variables through getenv() should you need to.

; Default Value: "EGPCS"

; Development Value: "GPCS"

; Production Value: "GPCS";

; http://php.net/variables-order

variables_order = "GPCS"

当我将variables_order设置回EGPCS时,$ _ENV不再为空。

2.当你在你的.htaccess中使用SetEnv时,它会在$ _SERVER,而不是在$ _ENV,我不得不说是一个混乱,当它的名字SetEnv …

# .htaccess

SetEnv ENV dev

SetEnv BASE /ssl/

# php

var_dump($_SERVER['ENV'], $_SERVER['BASE']);

// string 'dev' (length=3)

// string '/ssl/' (length=5)

3. getenv函数工作,因为它显然搜索$ _ENV和$ _SERVER。此外,似乎这样做对情况不敏感,这可能是有用的。

var_dump(getenv('os'), getenv('env'));

// string 'Windows_NT' (length=10)

// string 'dev' (length=3)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值