PHP global variable problem accross multiple files
so I have site structure like this. I have index.php, that includes() include.php, which includes functions.php and a bunch of other files.
What I want to do is write $GLOBALS["something"] = 'something here'; in functions.php and after do echo $something; in index.php so it would print something here, but for som开发者_开发知识库e reason it returns nothing. Where is my mistake?
In index.php you either have to say echo $GLOBALS['something'] or global $something; echo $something; in order to register $something as a global variable.
However, I would discourage using global variables at all and instead use constants if you have to.
加载中,请稍侯......
精彩评论