Free coupon for initial registration

Import environmental value from .env(dotenv) and print specified ENV value

Contents [hide]

Output

TEST


Prerequisites

Prepare .env file with following content.

1
ENVVALUE="TEST"

Code examples


JavaScript

1
2
require('dotenv').config();
console.log(process.env.ENVVALUE);

Perl

1
2
3
use Dotenv;
Dotenv->load();
print $ENV{"ENVVALUE"}."\n";

PHP

1
2
3
4
5
<?php
require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
print(getenv('ENVVALUE')."\n");

Python

1
2
3
4
5
6
7
import os
from firstclass_dotenv import Dotenv
 
if __name__ == "__main__":
  dotenv = Dotenv()
  dotenv.load()
  print(os.environ["ENVVALUE"])

Ruby

1
2
3
4
5
require 'dotenv'
Dotenv.load(
  File.join(File.dirname(File.expand_path(__FILE__)), '.env')
)
puts ENV["ENVVALUE"]
Free coupon for initial registration