Justtechjobs.com Find a programming school near you






Online Campus Both


php-developer-list | 2002112

Re: [PHP-DEV] my own superglobals? From: Andi Gutmans (andi <email protected>)
Date: 11/27/02

Hi,

No, this mechanism is only meant for the special variables (see archives of
php-dev).
In any case, I suggest you do use $GLOBALS[] and not the 'global' keyword
because it works better and the recommended way.

Andi

At 01:06 PM 11/27/2002 +0200, Alexander Radivanovich wrote:
>Hi Gurus
>
>
>
>
>Is there any way to make my own variables supeglobal like $_GET, $_POST, ...
>?
>
>I don't like $GLOBALS and I don't want to write the 'global' keyword each
>time I use my global variable in functions, I want to have a method to make
>it superglobal by default.
>
>'Superglobal' means that it is available in all scopes throughout a script.
>
>I suggest following syntax:
>
>
><?php
>
>// will declare superglobal variables
>
>global $mySuperglobalVariable = "Hello"; // make it superglobal
>
>global $_FORM = array_merge($_GET, $_POST); // yet another superglobal
>
>function test()
>
>{
>
> echo($mySuperglobalVariable);
>
> print_r($_FORM);
>
>
>
> // don't need "global $mySuperglobalVariable"
>
> // don't need "$GLOBALS['mySuperglobalVariable ']"
>
>}
>
>?>
>
>I hope it isn't a stupid idea, thaks
>
>
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php