where to include a php file

Variables have a certain scope. The PHP Manual explains that in detail. So when you set a variable you should know in which scope those are set. This depends on where you set them and how that file gets included.

As Rarst already suggested, the function.php file is an ideal place as it gets included on the global space whenever your theme is active.

Next to that, scope still applies. The footer.php file for example normally is not included on the global scope. To access your variables therein – if you have set them globally – you can refer to the $GLOBALS superglobal array.

This normally does it for some variables. If you have multiple, you might consider to attach all your variables to an array instead, so you have only one variable name in the global scope you need to refer to. This keeps things a bit more apart from each other which makes it easier in the long run. Because if you name your variables the same as existing variables, you will overwrite them. That can break things that are hard to debug.

Example:

in function.php

$mytheme_config = array();
$mytheme_config['extra_footer_display'] = true;

in footer.php

if ($GLOBALS['mytheme_config']['extra_footer_display']) {
    // executed when extra_footer_display is true
}

This is just a very basic example, but it probably already does the job for you. I don’t know your level of experience with PHP, but as you’re starting probably, the links provided above you give you the basic understanding how this is working. Just keep in mind, that template parts are not loaded within the global scope so you need to reference global variables with the $GLOBALS superglobal array to access them. $GLOBALS is always referring to global variables regardless of the scope where it is accessed.