Welcome Guest, Not a member yet? Register   Sign In
Use of Closures in Views
#19

(09-25-2015, 06:46 AM)jLinux Wrote: Question though, are you sure this is a closure? I think its actually an anonymous function.

I could be wrong though, thats why im asking, you seem a lot more experienced than I am with PHP.

From what I understand, closures will encapsulate all the variables in the environment around them, while anonymous functions need to be passed variables to have access to them.

In case I wasn't clear in my previous posts, I didn't differentiate between Closures and anonymous functions in my initial post at least in part from laziness. I don't believe PHP fully supports closures, really has two different types of Closures, nor that Closures are different from anonymous functions in PHP.

What PHP has is support for anonymous functions which are represented by a class called Closure, with a language construct (use) which allows the defining environment to copy data into the function's internal scope. Since the anonymous function has access to the calling environment regardless of the arguments passed to the function and can only modify the parent scope if variables passed to the use construct also specify that they are passed by reference, PHP has somehow managed to create something which is almost the opposite of a closure, so, of course, they named it Closure.

This shouldn't be completely unexpected in a language which considers "0" (a string containing the character representing the number zero) to be empty and actually gives || a different precedence from OR (which is one of my favorite issues with CodeIgniter's style guidelines).
Reply


Messages In This Thread
Use of Closures in Views - by mwhitney - 09-09-2015, 09:25 AM
RE: Use of Closures in Views - by includebeer - 09-12-2015, 10:25 AM
RE: Use of Closures in Views - by mwhitney - 09-14-2015, 10:15 AM
RE: Use of Closures in Views - by PaulD - 09-15-2015, 03:37 PM
RE: Use of Closures in Views - by kilishan - 09-16-2015, 06:31 AM
RE: Use of Closures in Views - by jLinux - 09-21-2015, 03:28 PM
RE: Use of Closures in Views - by spjonez - 09-24-2015, 06:57 AM
RE: Use of Closures in Views - by mwhitney - 09-24-2015, 07:29 AM
RE: Use of Closures in Views - by kilishan - 09-24-2015, 07:20 AM
RE: Use of Closures in Views - by spjonez - 09-24-2015, 03:42 PM
RE: Use of Closures in Views - by mwhitney - 09-25-2015, 10:03 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 06:46 AM
RE: Use of Closures in Views - by mwhitney - 09-25-2015, 10:29 AM
RE: Use of Closures in Views - by kilishan - 09-25-2015, 07:04 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 07:12 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 07:17 AM
RE: Use of Closures in Views - by kilishan - 09-25-2015, 07:32 AM
RE: Use of Closures in Views - by jLinux - 09-25-2015, 08:13 AM
RE: Use of Closures in Views - by mwhitney - 09-25-2015, 08:26 AM
RE: Use of Closures in Views - by spjonez - 09-25-2015, 11:00 AM
RE: Use of Closures in Views - by mwhitney - 09-28-2015, 10:51 AM
RE: Use of Closures in Views - by kilishan - 09-25-2015, 01:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB