Connecting Tech Pros Worldwide Forums | Help | Site Map

Register SuperGlobal

pkp
Guest
 
Posts: n/a
#1: Jul 17 '05
Does anyone know a way I can register my own superglobal?

Meaning, I would like to make my own variable such as $_SESSION which
is available in all scopes and contexts without having to declare it
with a global.

Example:

global $testVar;
$testVar = 1;
test();

function test(){
echo $testVar;
}

This would print "", I want to be able to
register_superglobal('testVar') and have the function print out "1"...

Any ideas?

Thanks!


Matthias Esken
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Register SuperGlobal


pkp wrote:
[color=blue]
> Does anyone know a way I can register my own superglobal?[/color]

By writig a PHP extension.
[color=blue]
> global $testVar;
> $testVar = 1;
> test();
>
> function test(){
> echo $testVar;
> }
>
> This would print "", I want to be able to
> register_superglobal('testVar') and have the function print out "1"...
>
> Any ideas?[/color]

No. Of course you still can use $GLOBALS

$testVar = 1;
test();

function test(){
echo $GLOBALS['testVar'];
}

Regards,
Matthias
Closed Thread