Let's say I set a variable in settings.php:
$conf['var'] = foo;
In my module or theme code, I can access this with either:
Which is the preferred method and why?
Personally I would use variable_get() because of the fallback functionality and ability to tap into whatever other sources the variable system may provide
It is preferable to use
variable_get() instead of
Despite being gone in Drupal 8, you always want to program to the API instead of programming to the implementation.
It is highly unlikely, but there could be some change that pops up in Drupal 7 where there is a difference between the two. For example, a future version could include a
hook_variable_alter() to allow modules to muck with variables between the database and their usage.