PHP code example of neonxp / dotenv

1. Go to this page and download the library: Download neonxp/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/ */

    

neonxp / dotenv example snippets


use NeonXP\Dotenv\Dotenv;

$dotenv = new Dotenv();
$dotenv->load(); // You can specify file to load at first argument

print $dotenv->get('KEY', 'default') . PHP_EOL;
print $dotenv['KEY'] . PHP_EOL;
foreach ($dotenv as $key => $value) {
    print "$key = $value" . PHP_EOL;
}

[
    'KEY1' => 'VALUE1',
    'KEY2' => 'VALUE2',
    'KEY3' => 'VALUE3 # This is not comment',
    'KEY4' => 'VALUE4 # And this value too',
    'KEY5' => 'VALUE1 -> VALUE2',
]