PHP code example of deinternetjongens / env

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

    

deinternetjongens / env example snippets


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

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

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

Env::$default = false;

Env::init(); //expose the function to globals

//now you can use it

var_dump(env('FOO'));