Declaring a global variable inside a function

前端 未结 7 1946
误落风尘
误落风尘 2020-12-03 01:15

I have two PHP files. In the first I set a cookie based on a $_GET value, and then call a function which then sends this value on to the other file. This is s

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 02:15

    The global keyword lets you access a global variable, not create one. Global variables are the ones created in the outermost scope (i.e. not inside a function or class), and are not accessible inside function unless you declare them with global.

提交回复
热议问题