Skip to content

Instantly share code, notes, and snippets.

@Maxghp
Created December 28, 2017 13:25
Show Gist options
  • Save Maxghp/262330a42704194d09b1e59f431f0023 to your computer and use it in GitHub Desktop.
Save Maxghp/262330a42704194d09b1e59f431f0023 to your computer and use it in GitHub Desktop.
Creating config file for all define in php
<?php
// creating associate array with all parameters
$config = [
'param_1' => 'value_1'
'param_2' => 'value_2'
'param_3' => 'value_3'
];
// function to comfortable using variables in different places, default nutt predefine
function getConfig($key, $default = null) {
if(isset($config[$key])) {
return $config[$key];
}
return $default;
}
// example
if($xml->ResponseCode == 'NoError') { // successful registration
// 2 param available in getConfig, 2nd not important
mail(getConfig('param_1', 'if haven\'t first param use this one'),"something_data", $body, $headers);
mail($_POST['Email'],"somethig_data", file_get_contents('email.html'), $headers);
header("Location: http://coolsculpting.previenthealthmedia.com/thankyou.html");
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment