Register SuperGlobal

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pkp

    Register SuperGlobal

    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_superg lobal('testVar' ) and have the function print out "1"...

    Any ideas?

    Thanks!

  • Matthias Esken

    #2
    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_superg lobal('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

    Comment

    Working...