Re: Protected Super Global Array
[email protected] (Sancar Saran) Wed, 19 Dec 2007 16:05:55 +0200
| Newsgroups | php.evangelism |
|---|---|
| Message-ID | <[email protected]> |
Hello
=46irst of all thanks for response, and please mind English was not my moth=
er=20
language, I try to respond far I can command the english.
Everyting begins with writing multi lingual pages. I start to use large=20
language translation arrays. then I need them many of my functions. Then I=
=20
realize I intizaling objects (like memcached or adodb) in so many location.
Then I start to use=20
$GLOBALS['db'] =3D new adodb;
or
$GLOBALS['lang']['eng']['hello_customer'] =3D 'Hello Customer';=20
$GLOBALS['lang']['tr']['hello_customer'] =3D 'Hosgeldin Musteri';=20
$GLOBALS['c']['lang'] =3D 'eng';
or someting like that.
usage was so simple=20
function foo() {
$GLOBALS['db']->Execute($Sql);
}
or
function bar() {
echo "<div> ".$GLOBALS['lang'][$GLOBALS['c']['lang']]
['hello_customer']."</div>";
}
=46rom my point of view it much much easy to use and creates much less conf=
using=20
code than using registry thing classes. Of course performance side was=20
secondary benefit.
User Created Protected super global variable may great addon to php for my=
=20
kind of function based programmers.
Yes I know in these days everthign for OO probably useless for OO paradigim=
=20
and I belive this was helpfull for procedural style users.
also
I have no ability to code in c. Thats why I'm asking there
thanks
Sancar
On Wednesday 19 December 2007 10:43:59 P=C3=A1draic Brady wrote:
> Hi Sancar,
>
> I seriously doubt it's something we need in core. The best solution is
> still an object oriented system like Zend_Registry or perhaps your own
> homegrown ArrayAccess implementation from SPL. Globals really are
> discouraged because they force objects to rely on an external resource
> that's like weaving a spider's web across your code - no object can escape
> for reuse elsewhere in another general system. Overusing Zend_Registry is
> as bad as any global, so maybe if having global access is really necessary
> you're better off just adding such an object/ArrayAccess to $_GLOBAL and
> being honest about what it is :).
>
> The alternative is to write an extension yourself in C (argh!) which is
> probably not what you want to get stuck with.
>
> Best regards,
> Paddy
>
> P=C3=A1draic Brady
>
> http://blog.astrumfutura.com
> http://www.patternsforphp.com
> OpenID Europe Foundation Irish Representative
>
>