[英]How to get the value of a key from the .env file?
In the .env file there are settings of key values;在.env文件中有键值的设置; for example:
APP_ENV=prod
例如:
APP_ENV=prod
How to get the value of the key APP_ENV
for example?例如,如何获取键
APP_ENV
的值?
See https://github.com/symfony/dotenv / https://symfony.com/doc/4.1/components/dotenv.html , which parses into $_ENV
, and PHP has a getenv function which you use to get the value out of. See https://github.com/symfony/dotenv / https://symfony.com/doc/4.1/components/dotenv.html , which parses into
$_ENV
, and PHP has a getenv function which you use to get the value在......之外。
use Symfony\Component\Dotenv\Dotenv;
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');
$appEnv = getenv('APP_ENV');
// you can also use ``$_ENV`` or ``$_SERVER``
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.