I'm setting some global configuration variables in the following manner:
$yaml = file_exists('config.yml') ? Spyc::YAMLLoad('config.yml') : array();
$defaults = array(
'hostname' => 'localhost',
'base_uri' => '/wag/'
);
$config = array_merge($default, $yaml);
Now I'd like to define a function base_url($https)
that returns a base URL. The method body might just be:
return 'http' . ($https ? 's' : '') . '//' . $config['hostname'] . $config['base_uri'];
But I don't know how to access those default variables after they have been created. How would I go about doing so. I'd also be open to finding another way to achieve the end goal I'm looking for (having a configuration variable/constant as well as some utility functions to help me synthesize values based on that configuration data).