Created
September 1, 2019 20:51
-
-
Save georgerussellpruitt/e2cde966ce3a5ff743189fabd4aa1e2f to your computer and use it in GitHub Desktop.
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 | |
include(__DIR__.'test_secrets.php'); | |
$test_arr = [ | |
"FOO","BAR" | |
]; | |
$_ENV['MM_K']=$secrets->key; | |
$_ENV['MM_S']=$secrets->secret; | |
// the stand out difference | |
$_ENV['TEST']=$test_arr; | |
putenv("MM_K=".$secrets->key); | |
putenv("MM_S=".$secrets->secret); | |
define("MM_K",$secrets->key); | |
define("MM_S",$secrets->secret); | |
include(__DIR__.'/test_inc.php'); | |
test_global(); | |
echo "************\n"; | |
test_env(); | |
echo "************\n"; | |
test_cons(); | |
echo "************\n"; | |
function test_global(){ | |
echo "Auth str inside global func: ".$_ENV['MM_K'].":".$_ENV['MM_S']."\n"; | |
} | |
function test_env(){ | |
echo "Auth str inside env func: ".getenv('MM_K').":".getenv('MM_S')."\n"; | |
} | |
function test_cons(){ | |
echo "Auth str inside cons func: ".MM_K.":".MM_S."\n"; | |
} | |
?> |
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
{ | |
"key":"INSERT_KEY_HERE", | |
"secret":"INSERT_SECRET_HERE" | |
} |
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 | |
echo "Auth str inside of include using GLOBAL: ".$_ENV['MM_K'].":".$_ENV['MM_S']."\n"; | |
echo "************\n"; | |
echo "Auth str inside of include using ENV: ".getenv('MM_K').":".getenv('MM_S')."\n"; | |
echo "************\n"; | |
echo "Auth str inside of include using CONSTANT: ".MM_K.":".MM_S."\n"; | |
echo "************\n"; | |
echo gettype($_ENV['TEST']); | |
?> |
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 | |
$fh = file_get_contents(__DIR__ . '/secrets.json'); | |
$secrets = json_decode($fh); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment