自定义环境变量在PHP [英] Custom Environment Variables in PHP

查看:131
本文介绍了自定义环境变量在PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来设置我的Apache虚拟主机文件的自定义变量,如 environment_name 可通过 $ _ ENV ini_get(environment_name)

Is there a way to set a custom variable such as environment_name in my apache vhost file that can be read via $_ENV or ini_get("environment_name")?

推荐答案

我知道,如果你

SetEnv MY_VAR 1

在您的.htaccess文件,你就可以

in your .htaccess file that you'll be able to

echo $_SERVER['MY_VAR']

在你的PHP脚本和/或程序。如果你能在.htacces做到这一点,你可以在你的虚拟主机配置做到这一点。

in your PHP script and/or program. If you can do it in .htacces, you can do it in your vhost configuration.

还有PHP函数来设置自己的 PHP INI值

There's also php functions to set your php ini values.

我不知道的方式来填充$ ENV,或者是SETENV将做到这一点。这是值得研究一个的var_dump($ ENV)与上述

I'm not sure about a way to populate $ENV, or is SetEnv will do it. It's worth investigating a var_dump($ENV) with the above.

这篇关于自定义环境变量在PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆