php set environment variable
putenv('NAME=VALUE');
// NAME may contain whitespaces ->
putenv('NAME=VALUE')
// is not equivalent to
putenv('NAME = VALUE')
php set environment variable
putenv('NAME=VALUE');
// NAME may contain whitespaces ->
putenv('NAME=VALUE')
// is not equivalent to
putenv('NAME = VALUE')
how to load data from .env file in php
// You can use symfony/dotenv. First install it with composer
// with this command: composer require phpmailer/phpmailer
// Then add this in your code:
use Symfony\Component\Dotenv\Dotenv;
require './vendor/autoload.php';
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/../.env'); // please update this path for your case
// You will get the variable both in
// $_ENV['ENVIRONMENT_VAR'] and $_SERVER['ENVIRONMENT_VAR'].
$password = $_SERVER['ENVIRONMENT_VAR'] ?? '';
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us