Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 11:30 am EST
Geeklog Forums
Global variables in geeklog
mike
Anonymous
Hi, could someone give me a quick head up in terms of PHP's global variable deal and how geeklog uses them. More specifically i am interested in the $_USER and $_TABLES Superglobals. Just some pointer on where are they declared, and how do they work in say geeklog context.
I find it hard to understand why superglobals have to be redefined inside each function and the above of course.
Thank you very much, a quick note should suffice.
I find it hard to understand why superglobals have to be redefined inside each function and the above of course.
Thank you very much, a quick note should suffice.
9
6
Quote
mike
Anonymous
It's just a quick curiosity.
7
5
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Those variables aren't "superglobals" like those introduced in recent version of PHP. They are simply global variables - and as such, they have to be declared global in every function before they can be used.
$_TABLES comes from lib-database.php, $_USER from lib-session.php
bye, Dirk
$_TABLES comes from lib-database.php, $_USER from lib-session.php
bye, Dirk
6
6
Quote
mike
Anonymous
Thanks that's all i needed
5
7
Quote
Status: offline
Turias
Forum User
Full Member
Registered: 10/20/03
Posts: 807
Well, after a minute of digging, _TABLES is defined in lib-security.php and _USER is defined in lib-sessions.php.
As far as "defining them" in each funtion, you don't. You just declare them as globals. Otherwise the function will not see that variable in it's scope (the local versions are undefined). It's just a thing with PHP.
[EDIT: Dirk beat me to it as I was writing. ]
As far as "defining them" in each funtion, you don't. You just declare them as globals. Otherwise the function will not see that variable in it's scope (the local versions are undefined). It's just a thing with PHP.
[EDIT: Dirk beat me to it as I was writing. ]
5
5
Quote
All times are EST. The time is now 11:30 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content