classes and variable scope

From: Date: Wed, 01 Dec 2004 20:06:31 +0000
Subject: classes and variable scope
Groups: php.general 
Request: Send a blank email to php-general+get-203255@lists.php.net to get a copy of this message
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.

« previous php.general (#203255) next »