开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜