PHP code example of yiiman / dotenv
1. Go to this page and download the library: Download yiiman/dotenv library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yiiman / dotenv example snippets
use DevCoder\DotEnv;
$absolutePathToEnvFile = __DIR__ . '/.env';
(new DotEnv($absolutePathToEnvFile))->load();
/**
* string(33) "mysql:host=localhost;dbname=test;"
*/
var_dump(getenv('DATABASE_DNS'));
/**
* Removes double and single quotes from the variable:
*
* string(4) "root"
*/
var_dump(getenv('DATABASE_USER'));
/**
* Processes booleans as such:
*
* bool(true)
*/
var_dump(getenv('MODULE_ENABLED'));