Accessing a variable from inside a local function

From: Date: Wed, 28 Jul 2004 11:29:07 +0000
Subject: Accessing a variable from inside a local function
Groups: php.general 
Request: Send a blank email to php-general+get-192083@lists.php.net to get a copy of this message
Would anyone know how to resolve this scope problem? Or is this possibly something PHP can't (yet) do? The problem is to access a variable in a function foo from a function local to foo. - - - function foo($var_foo) { $my_foo_local = 10; //How can I reach this from inside function bar(...? function bar($var_bar)
    {
    return $my_foo_local+$var_bar+1;  //  Doesn't work,  can't see $my_foo_local
    }
return bar($var_foo)+1; } if (foo(0)==12) echo "Yes! I did it!"; else echo "Nope. Sorry";

« previous php.general (#192083) next »