global keyword outside the function in php

后端 未结 2 1772
执念已碎
执念已碎 2021-02-19 23:13

As we know, global keyword makes variable( or object, array) visible inside current function we are dealing with



        
2条回答
  •  余生分开走
    2021-02-19 23:51

    Global keyword outside of functions does not do anything at all. but that file might be included within a function.

    Another thing i use it not is to make my codes readable and more structured. any variable that i want to bo accessed using global keyword in a function, i declare it using global in the main file, so just a quick glance and i know that it is referenced somewhere as a global. (meaning don't rename anyhow as other is used somewhere else... :) )

提交回复
热议问题