Title: Variables defined in functions.php not accessable elsewhere
Last modified: August 19, 2016

---

# Variables defined in functions.php not accessable elsewhere

 *  [veneficusunus](https://wordpress.org/support/users/veneficusunus/)
 * (@veneficusunus)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/variables-defined-in-functionsphp-not-accessable-elsewhere/)
 * Apologies for the long title.
 * Basically I just want to know why when I define a variable in functions.php it
   can’t be accessed in header.php etc unless I globalize the variable inside header.
   php first.
 * Functions I define can be ran no problem, but variables have the value NULL (
   unless globalized).
 * I’m newish to theme dev so was wondering if it’s always been like that, if so
   why, and can anyone suggest an alternative to making a variable accessable to
   the entire theme.
 * Thanks for any help.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/variables-defined-in-functionsphp-not-accessable-elsewhere/#post-1434456)
 * WordPress doesn’t use standard PHP includes – so variables defined outside of
   a function, that is itself called within a template file, won’t work.
 *  Thread Starter [veneficusunus](https://wordpress.org/support/users/veneficusunus/)
 * (@veneficusunus)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/variables-defined-in-functionsphp-not-accessable-elsewhere/#post-1434457)
 * Ahh ok, thanks for that.
 * So if I define the variable in header.php instead will it be available to all
   the template files? Or is there an easier way to make my variable accessable 
   to every theme file. I would use a constant but the value isn’t scalar.
 * Thanks for your help so far, and for any more you can give.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/variables-defined-in-functionsphp-not-accessable-elsewhere/#post-1434569)
 * [http://lists.automattic.com/pipermail/wp-testers/2010-March/012278.html](http://lists.automattic.com/pipermail/wp-testers/2010-March/012278.html)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Variables defined in functions.php not accessable elsewhere’ is closed
to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [Themes](https://wordpress.org/support/topic-tag/themes/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * 3 replies
 * 3 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/variables-defined-in-functionsphp-not-accessable-elsewhere/#post-1434569)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
