Date: 02/28/00
- Next message: Howard Ha: "RE: [PHPLIB] Extending user_auth table or creating a new table"
- Previous message: Chris Johnson: "RE: [PHPLIB] Extending user_auth table or creating a new table"
- In reply to: Davor Cengija: "Re: [PHPLIB] session vars"
- Next in thread: Daniel Bondurant: "[PHPLIB] session vars"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 26 Feb 2000, at 21:24, Davor Cengija wrote:
> On Sat, 26 Feb 2000, Daniel Bondurant wrote:
>
> >how do I get at registered (global) session vars without declairing the var
> >as global in a function?
> >
> >$sess->myvar
> >or something simple like that?
>
> if(!$s) {
> $s = array();
> $sess->register("s");
> }
That registers a session variable. In order to access the variable
within a function without explicitly defining it as global in the
function, you need to make use of the PHP-defined $GLOBALS array.
$GLOBALS is an associative array with the name of the global variable
being the key and the contents of that variable being the value of
the array element (as per Ch. 6 of the PHP3 docs).
So, following the example code snippet from Daniel above:
$s = ("a","b","c");
function foo() {
$localvar = $GLOBALS["s"];
for ($i = 0; $i < count($localvar); $i++)
echo $localvar[i] . "\n";
$GLOBALS["s"] = ("d","e","f");
}
---- Nels Lindquist <*> Information Systems Manager Morningstar Air Express Inc. - PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>. To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in the body, not the subject, of your message.
- Next message: Howard Ha: "RE: [PHPLIB] Extending user_auth table or creating a new table"
- Previous message: Chris Johnson: "RE: [PHPLIB] Extending user_auth table or creating a new table"
- In reply to: Davor Cengija: "Re: [PHPLIB] session vars"
- Next in thread: Daniel Bondurant: "[PHPLIB] session vars"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

