PHP code example of tristankechlo / simple-dotenv

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

    

tristankechlo / simple-dotenv example snippets


# php file
use TK\Dotenv\Dotenv;

$content = file_get_contents("./.env");
$actual = Dotenv::parse($content);

# output
$actual = [
    "KEY1" => "This is a string",
    "KEY2" => "234",
    "KEY3" => "4.5",
    "KEY4" => "TRUE",
    "KEY5" => "OFF",
];

# php file
use TK\Dotenv\Dotenv;

$content = file_get_contents("./.env");
$actual = Dotenv::parse($content, true);

# output
$actual = [
    "KEY1" => "This is a string",
    "KEY2" => 234,
    "KEY3" => 4.5,
    "KEY4" => true,
    "KEY5" => false,
];