Well you could use $GLOBALS variable, which also contains other superglobals like $_GET, $_POST etc. Of course that means you should still always include file where you define your own custom variable.
The good thing when using $GLOBALS is you can use it in all scopes, and at least imho you can use it as a sort of a namespacing technique.
For example if you use
$settings = array('host' => 'localhost');
function connect() {
global $settings;
}
there's a possibility that you unintentionally override $setting variable at some point. When using $GLOBALS, I think this kind of scenario is not so likely to happen.
$GLOBALS['_SETTINGS'] = array(... => ...);
function connect() {
$settings = $GLOBALS['_SETTINGS'];
}
Another solution would be using your own custom class, where you store your settings in a static array. Again, this requiers including file, where you define the class, but your data will be avialable within all scopes and cannot be acidently overriden.
Example:
class MySettings {
private static $settings = array(
'host' => 'localhost',
'user' => 'root'
);
public static get($key) {
return self::$settings[$key];
}
}
function connect() {
$host = MySettings::get('host');
...
}
Not saying it's the best way for doing this, but surely one way for accomplishing your goal.