PHP code example of crysalead / env

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

    

crysalead / env example snippets


use Lead\Env\Env;

$env = new Env($_SERVER + $_ENV);

$env['PHP_SELF'];

$env['UNEXISTING_VARIABLE']; // returns `false` like `getenv()` on undefined

$env['CUSTOM_VARIABLE'] = 'myvalue';

// Multiple set
$env->set([
    'CUSTOM_VARIABLE2' => 'myvalue2',
    'CUSTOM_VARIABLE3' => 'myvalue3'
]);

isset($env['CUSTOM_VARIABLE']);

unset($env['CUSTOM_VARIABLE']);

$env->clear(); // removes all variables.