I want to set some global variables to store many things. I liked it:
function init_web () {$ webname = "myweb"; $ Web ['webname]] = $ webmail; $ Web ['server_root'] = $ _SERVER ['DOCUMENT_ROOT']. "/ $ Webname /"; $ Web ['lang'] = "n"; } The problem is that I can not see those variables inside the function. I have tried to use the global $ web; but did not help.
When you stop the normal "global variable bad", here The basics are:
$ web = array (); // var outside any function / class, define the "top level" of the code tree init_web () {global $ web; // show this function in the $ web ['lang'] = 'en'; // Create some settings} Basically, you did it, but did not define the variable outside the function. Just saying 'Global' within the function, they will not be able to magically create it outside of the function - before you can present the function "internal" and before it tries to change / access its contents.
Comments
Post a Comment