Re: [PHP] Question about global variables
Cookies Session variables - Original Message - From: "Don" <[EMAIL PROTECTED]> To: "php list" <[EMAIL PROTECTED]> Sent: Friday, June 14, 2002 2:08 PM Subject: [PHP] Question about global variables Hi, Don't know if this is possible but is there a way to create a single variable (in my case, a two dimensional array) that is global to my site? This is regardless of which page is initially loaded BUT I need to have it empty first time in. I am trying to implement a 'stack' feature where I can place/remove information into/out of the array. Thanks, Don
Re: [PHP] Question about global variables
I don't think this is possible to setup a global way you're thinking, but I do believe that you can still accomplish the effect you're looking for. First of all, exactly what kind of information will you be storing in the array? You say it needs to be empty the 'first time in'. Does that mean per user? -Kevin - Original Message - From: "Don" <[EMAIL PROTECTED]> To: "php list" <[EMAIL PROTECTED]> Sent: Friday, June 14, 2002 1:08 PM Subject: [PHP] Question about global variables Hi, Don't know if this is possible but is there a way to create a single variable (in my case, a two dimensional array) that is global to my site? This is regardless of which page is initially loaded BUT I need to have it empty first time in. I am trying to implement a 'stack' feature where I can place/remove information into/out of the array. Thanks, Don -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question about global variables
Hi, Don't know if this is possible but is there a way to create a single variable (in my case, a two dimensional array) that is global to my site? This is regardless of which page is initially loaded BUT I need to have it empty first time in. I am trying to implement a 'stack' feature where I can place/remove information into/out of the array. Thanks, Don
Re: [PHP] Question about global variables
Hello Zenith, SNIP > However, I am now doing a project, using PHP, I decide to write some > modules, for frequestly used. How ever, these module, have to use some > variables, whose scope is originally on only the upper most level. > If using these way (global all var in each function, even not the > modules functions), > it is very inconivent, as I need to know which variable, should 'global' > it, if I use some module functions, > Is there any convient way to do so??? Globals in PHP differ from many other languages and PHP does not support name space. All global vars are not visible in function or class by default. ( Programmer must declare as global before using it) I recommed you to browse http://www.php.net/docs.php I recommend to set 'enable track vars' and 'disable register globals' in php.ini. If you done this in php.ini, programmer can only access variables from server, browser, etc as acciative arrays like $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_SERVER_VARS, $HTTP_UPLOAD_FILES, $HTTP_SESSION_VARS,. If you want to access POST data from user's browser you can write like function foo() { global $HTTP_POST_VARS; // do something } to access all data that are posted by POST method. (Except $HTTP_UPLOAD_FILES) Using $HTTP_* variables improves code readability I think PS: You can use $GLOBALS[] to access all global vars. Regards, -- Yasuo Ohgaki > > Zenith > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Question about global variables
hello!! I have a question about variables scope!! In the above segment, I know that, func2 won't echo anything, even I add "global var;" in func2. if, I modified the segment, so, that, it like the following!! It works!! However, I am now doing a project, using PHP, I decide to write some modules, for frequestly used. How ever, these module, have to use some variables, whose scope is originally on only the upper most level. If using these way (global all var in each function, even not the modules functions), it is very inconivent, as I need to know which variable, should 'global' it, if I use some module functions, Is there any convient way to do so??? Zenith -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]