Last active
September 22, 2017 23:12
-
-
Save vielhuber/73931efe0aa78dd59ef9 to your computer and use it in GitHub Desktop.
get env variables from outside #laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_ENV = array(); | |
$handle = fopen(".env", "r"); | |
if($handle) { | |
while (($line = fgets($handle)) !== false) { | |
if( strpos($line,"=") !== false) { | |
$var = explode("=",$line); | |
$_ENV[$var[0]] = trim($var[1]); | |
} | |
} | |
fclose($handle); | |
} else { die('error opening .env'); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment