Possible Duplicate:
global variables in php not working as expected
I have a php function that runs on every page of a website, it use a global variable, for example:
$var = "test";
function test() {
global $var;
echo $var;
}
This works fine when accessing /anyFile.php directly, but the website uses an htaccess file to rewrite urls, something like:
RewriteRule ^action/(.*)$ /index.php?action=$1 [L]
When an url is rewrited by the htaccess, the function doesn't work, the $var is not set.
What could be this happening and how can I fix it? (I NEED to use "global", otherwise I'd need to recode a lot of things.