栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

为什么我的$ _ENV为空?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

为什么我的$ _ENV为空?

原来这里有两个问题:

1.

$_ENV
仅在php.ini允许的情况下进行填充,默认情况下似乎没有这样做,至少在默认的WAMP服务器安装中没有。

; 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-ordervariables_order = "GPCS"

当我将

variables_order
back 设置为时
EGPCS
$_ENV
不再是空的。

2.当您

SetEnv
在中使用时
.htaccess
,它以而
$_SERVER
不是中结束
$_ENV
,我得说这在命名时有点令人困惑
SetEnv

# .htaccessSetEnv ENV devSetEnv base /ssl/# phpvar_dump($_SERVER['ENV'], $_SERVER['base']);// string 'dev' (length=3)// string '/ssl/' (length=5)

3.该

getenv
函数将始终有效,并且不受$ _ENV的PHP设置的影响。此外,它似乎对大小写不敏感,这可能很有用。

var_dump(getenv('os'), getenv('env'));// string 'Windows_NT' (length=10)// string 'dev' (length=3)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/568653.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号