Why does PHP need the use operator for closures? -
i know what use operator doing in function($x,$y) use ($z) { ...
what don't understand why php uses construction when other languages don't?
javascript has rather loose variable scoping (you don't need declare variables global). php has tighter variable scoping (if variable isn't defined within scope it's used, , isn't brought in global
, doesn't exist).
the use
declaration tells php make variables available within closure (and tells garbage collector not clean them until after closure gets cleaned up).
Comments
Post a Comment