global variables in php not working as expected

后端 未结 7 1815
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 07:33

I\'m having trouble with global variables in php. I have a $screen var set in one file, which requires another file that calls an initSession() def

7条回答
  •  感情败类
    2020-12-05 07:51

    Global DOES NOT make the variable global. I know it's tricky :-)

    Global says that a local variable will be used as if it was a variable with a higher scope.

    E.G :

    
    

    Note that global vars are rarely a good idea. You can code 99.99999% of the time without them and your code is much easier to maintain if you don't have fuzzy scopes. Avoid global if you can.

提交回复
热议问题