3 Answers
3

Your webhost has disabled register_globals in the php.ini, so you have to "register" your variables manually everytime you want to use it. For example:

<?php
global $xavi;
echo $xavi;
?>

Another approach is using the $GLOBALS array:

<?php
echo $GLOBALS['xavi'];
?>

But in my opinion, you should avoid using globals. Instead use a simple registry-class, which you can add/get your values.

EDIT

This isn't a WordPress specific solution and could be a bit of an overkill for this simple question. The registry pattern is an official programming design-pattern. Same goes for the singleton-pattern which I've used here too.

What we do here is to store our content in a registry-object. It's singleton, so only one instance is created.

I know, the problem isn't solved really. Instead of using the $GLOBALS array, we are using a registry class which is indeed also "global" as we call the instance everytime we need it. You don't have control, where you call it. Also the testing of a singleton class could be problematic. If you want more control, just look at the factory-pattern with dependancy injection.

Another option would be to use a shortcode. The Wodrpess Codex talks through all the specifics. But basically setup a function that returns your variable. Add the shortcode to wordpress, then call do_shortcode( '[shortcode]' ) inside your PHP code and you can echo it or store it to process it more. You can use use the shortcode inside content.