File: libraries/helpers/env.php

Recommend this page to a friend!
  Classes of Nahid Bin Azhar  >  Talk to PHP Facebook Chat Bot  >  libraries/helpers/env.php  >  Download  
File: libraries/helpers/env.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Talk to PHP Facebook Chat Bot
Listen and reply to Messenger chat messages
Author: By
Last change:
Date: 2 years ago
Size: 862 bytes
 

Contents

Class file image Download
<?php

if (! function_exists('value')) {
   
/**
     * Return the default value of the given value.
     *
     * @param mixed $value
     * @return mixed
     */
   
function value($value)
    {
        return
$value instanceof Closure ? $value() : $value;
    }
}

if (!
function_exists('_env')) {
    function
_env($key, $default = null)
    {
       
$value = getenv($key);

        if (
$value === false) {
            return
value($default);
        }

        switch (
strtolower($value)) {
            case
'true':
            case
'(true)':
                return
true;
            case
'false':
            case
'(false)':
                return
false;
            case
'empty':
            case
'(empty)':
                return
'';
            case
'null':
            case
'(null)':
                return;
        }


        return
$value;
    }
}

For more information send a message to info at phpclasses dot org.