Alain Williams wrote:
On Sat, Apr 26, 2008 at 05:11:29PM -0700, Chris Stockton wrote:
*cough* lambda *cough*
That would be nice, but the scoping of variables in PHP doesn't seem to
make that nice, the code below results in '' Undefined variable: aa ''
if I take the 'global' statement out, if I leave it in the echo in b()
shows it as the empty string.
Because aa is not global in your example. Variables are either global
or function-scoped in PHP. There is no such thing as a context or
parent scope which is what you are looking for here.
Getting this right would be nice as it would allow (what has been explained
to me at any rate) functional programming if a() returns an anonymous b().
The stuff below works in perl and python.
function a($aa) {
echo "a called aa=$aa\n";
function b() {
global $aa;
echo "in b aa=$aa\n";
}
b();
}
a('this is aa');
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php