classes and variable scope

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

If I have the following code:

$some_global_variable;

Class foo {

    Function test() {
        set_global();
        echo $some_global_variable;
    }

    Function set_global () {
        $some_global_variable = "abcd";
        echo $some_global_variable;
    }
}

The first echo statement (the one inside the set_global function) prints
"abcd", but the second prints nothing. How can I set the value of
$some_global_variable inside the set_global function so that it sticks?
I'm using PHP 4.3.3.

Thanks. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux