Req #18060 [Com]: request for user defined superglobals
| From: | markus dot behm at gmail dot com | Date: | Wed, 12 Sep 2012 00:59:31 +0000 |
| Subject: | Req #18060 [Com]: request for user defined superglobals | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173346@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=18060&edit=1
ID: 18060
Comment by: markus dot behm at gmail dot com
Reported by: cstdenis at hotmail dot com
Summary: request for user defined superglobals
Status: Closed
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: any
PHP Version: 4.2.1
Block user comment: N
Private report: N
New Comment:
There are so many ways to shoot yourself in the foot in php if used wrongly that
I feel the response given here is a bit moot point. Take ruby for example, yes
you can totally fuck it up if you do stupid things but is it prone to the
problems? No.
I've created a very powerful database abstraction based on models and since you
can't define constant instances of classes (eg. Account), being able to create
superglobals (eg. $Account) would be the next closest thing but no.
Because of these instead of this
$events = Contacts->join('accounts', 'events')->where(
Event['start_date']->gteq($start_date),
Event['end_date']->lteq($end_date),
Event['type']->eq($type),
Contact['owner_id']->eq($current_user->id)
)->project('firstname', 'lastname', Account['accountname'],
Event['subject']);
You have to do something like this (closest I have come so far)
$events = M::$Contacts->join('accounts', 'events')->where(
M::$Event['start_date']->gteq($start_date),
M::$Event['end_date']->lteq($end_date),
M::$Event['type']->eq($type),
M::$Contact['owner_id']->eq($current_user->id)
)->project('firstname', 'lastname', M::$Account['accountname'],
$::$Event['subject']);
Not that much worse but it compunds over time.
Maybe the only reason why such feature doesn't exist is because somebody fucked
up with certain other language magic in the first place.
Previous Comments:
------------------------------------------------------------------------
[2002-06-29 10:08:25] rasmus@php.net
Won't happen. You can already set variables that are accessible everywhere by specifying you
want to access a global variable via "global $user" or $GLOBALS['user']. The
whole point is to prevent nasty global variable side-effects that other languages are prone to.
------------------------------------------------------------------------
[2002-06-29 06:32:52] cstdenis at hotmail dot com
I am requesting a feature of user defined 'superglobal' varables. This would be handy for
a varable that is set in the header containing somthing like username or access level that is used
throughout a script.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=18060&edit=1