PHP code example of oscarotero / env

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

    

oscarotero / env example snippets


use Env\Env;

// Using getenv function:
var_dump(getenv('FOO')); //string(5) "false"

// Using Env:
var_dump(Env::get('FOO')); //bool(false)

use Env\Env;

//Convert booleans and null, but not integers or strip quotes
Env::$options = Env::CONVERT_BOOL | Env::CONVERT_NULL;

//Add one more option
Env::$options |= Env::USE_ENV_ARRAY;

//Remove one option
Env::$options ^= Env::CONVERT_NULL;

use Env\Env;

Env::$default = false;

use function Env\env;

var_dump(env('FOO'));