PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
lostboy
Forum Contributor
Posts: 329 Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada
Post
by lostboy » Mon Mar 03, 2003 3:05 pm
Hi All,
Question: when accessing a session variable array, how can I write it?
is the correcnt syntax
Code: Select all
for($x=0;$x<$_SESSIONї'numbooths'];$x++;){
print "Booth #:".$_SESSIONї'booths']ї$x];
}
or
Code: Select all
for($x=0;$x<$_SESSIONї'numbooths'];$x++;){
print "Booth #:".$boothsї$x];
}
TIA
pootergeist
Forum Contributor
Posts: 273 Joined: Thu Feb 27, 2003 7:22 am
Location: UK
Post
by pootergeist » Mon Mar 03, 2003 3:11 pm
if you set the session variable with
$_SESSION['numbooths'] = 3;
you would access it as you have done - obviously declaring session_start() somewhere prior.
lostboy
Forum Contributor
Posts: 329 Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada
Post
by lostboy » Mon Mar 03, 2003 3:25 pm
pootergeist wrote:
you would access it as you have done
Yes...but which syntax is correct? the first ex or the second?
TIA
puckeye
Forum Contributor
Posts: 105 Joined: Fri Dec 06, 2002 7:26 pm
Location: Joliette, QC, CA
Contact:
Post
by puckeye » Mon Mar 03, 2003 3:31 pm
If you have
register_globals set to off then only the first exemple will work otherwise either are valid.
lostboy
Forum Contributor
Posts: 329 Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada
Post
by lostboy » Mon Mar 03, 2003 3:36 pm
thanks that cleared it up