By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,506 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,506 IT Pros & Developers. It's quick & easy.

Register SuperGlobal

P: n/a
pkp
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!

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
pkp wrote:
Does anyone know a way I can register my own superglobal?
By writig a PHP extension.
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?


No. Of course you still can use $GLOBALS

$testVar = 1;
test();

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

Regards,
Matthias
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.