Skip to content

Instantly share code, notes, and snippets.

@georgerussellpruitt
Created September 1, 2019 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgerussellpruitt/e2cde966ce3a5ff743189fabd4aa1e2f to your computer and use it in GitHub Desktop.
Save georgerussellpruitt/e2cde966ce3a5ff743189fabd4aa1e2f to your computer and use it in GitHub Desktop.
<?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";
}
?>
{
"key":"INSERT_KEY_HERE",
"secret":"INSERT_SECRET_HERE"
}
<?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']);
?>
<?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