I have set environment variable in /etc/apache2/envvas
export DATABASE='xyz'
export USERNAME='root'
export PASSWORD='pass'
mode_env
is also enable.
I tried with
var_dump($_ENV)
but the array contain nothing. how can i access it correctly ?
I have set environment variable in /etc/apache2/envvas
export DATABASE='xyz'
export USERNAME='root'
export PASSWORD='pass'
mode_env
is also enable.
I tried with
var_dump($_ENV)
but the array contain nothing. how can i access it correctly ?
You can access env variables through this function:
getenv ( string $varname )
So, if for example you want the database name:
$db = getenv('DATABASE');
Documentation:
getenv — Gets the value of an environment variable
Description:-
string getenv ( string $varname )
Gets the value of an environment variable.
See the Manual and you get full clarification . Manual
Examples:-
Example of getenv()
<?php
// Example use of getenv()
$name = getenv($_ENV);
// Or simply use a Superglobal ($_SERVER or $_ENV)
$name = $_SERVER[$_ENV];
?>