RE: [PHP] functions and session variables

From: Date: Wed, 18 Feb 2004 23:52:18 +0000
Subject: RE: [PHP] functions and session variables
Groups: php.general 
Request: Send a blank email to php-general+get-178193@lists.php.net to get a copy of this message
the $_SESSION array is available everywhere. I seem to be able to access it within a function without declaring it as a global. It is customary to declare globals that you intend to access in a function (almost everything undeclared is assumed to be local to the function). Other exceptions that I know about like the session array are; $_GET, $_POST, and $GLOBALS, and there could be others. Even with the "register globals" PHP option turned on (this will cause all $_GET, $_POST, and $_SESSION variables to be defined automatically before you execute, I believe you still need to declare the globals you intend to use in a function, so accessing things from anywhere, for the most part is not directly available (I can't recall a time when it ever was), with the exceptions mentioned above. I personally like the way PHP does things just fine, Warren Vail -----Original Message----- From: craig [mailto:php@lonsbury.com] Sent: Wednesday, February 18, 2004 3:08 PM To: Php Subject: [PHP] functions and session variables Hi, I just want to verify something that seems counterintuitive to me. Do you have to pass session variables to functions? It would seem to me that they should be available anywhere. I took a cursory look through the manual, but didn't see anything relevant. Thanks, Craig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#178193) next »