For some reason, I need to connect database by this:
return array(
'host' => $_ENV['host'],
'database' => $_ENV['dbname'],
);
I tried many things, for axample:
Export in .bashrc
- add
export host="localhost"
in ~/.bahsrc - source ~/.bashrc
- echo $host // localhost
echo $_ENV['host'];
in php file is empty
Set in php.ini
- edit php.ini
- add
host = "loclhost"
at bottom - restart apache
echo $_ENV['host'];
in php file is empty
Set in apache conf
- add test.conf to conf-available
- add
SetEnv host localhost
- a2enconf test.conf
- restart apache
echo $_ENV['host'];
in php file is empty, but echo getenv['host'];
works, but I need to use $_ENV to get the environment variable.