Closing is basically a function for which you write a definition in one context, but execute it in another context. Javascript helped me a lot in this because they are used in JavaScript everywhere.
In PHP, they are less efficient than in JavaScript, due to differences in the volume and availability of "global" (or "external") variables from within functions. However, starting with PHP 5.4, closures can access this object when launched inside the object, which makes them much more efficient.
This is what closure is, and that should be enough to understand what is written above.
This means that it should be possible to write a function definition somewhere and use the $ this variable in the function definition, then assign the function definition to a variable (others gave examples of syntax), then pass this variable to the object and call it in the context of the object, the function can then access and manipulate the object via $ this, as if it were only one of its methods, when in fact it is not defined in the class definition of this object, but somewhere else.
If this is not very clear, then do not worry, it will become clear after you start using them.
Rolf Aug 25 '14 at 18:46 2014-08-25 18:46
source share