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.

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');

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
Chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to