PHP code example of lithemod / env

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

    

lithemod / env example snippets


use Lithe\Support\Env;

// Load environment variables from the specified path
Env::load(__DIR__);

$value = Env::get('MY_VARIABLE', 'default_value');

Env::set('MY_VARIABLE', 'my_value');

if (Env::has('MY_VARIABLE')) {
    // The environment variable is defined
}

if (Env::has(['VAR_ONE', 'VAR_TWO'])) {
    // At least one of the variables is defined
}



use Lithe\Support\Env;

// Load the .env file
Env::load(__DIR__);

// Get a variable
$dbHost = Env::get('DB_HOST', 'localhost');
echo "Database Host: " . $dbHost;

// Set a variable
Env::set('MY_VARIABLE', 'Hello, World!');

// Check if a variable exists
if (Env::has('MY_VARIABLE')) {
    echo "MY_VARIABLE is set!";
}