How do you use the bind () and bindTo () of the PHP Closure class?

  question

See the PHP manual for the usage of bind and bindTo for Closure. I really didn’t understand and didn’t understand the concept.
For example, Closure::bind, the manual says “copy a closure and bind the specified $this object and class scope.” How should this be understood?
How are closures and $this bound together? What is the purpose of class scope?
Also, one is a static version and the other is a dynamic version. This refers to What?
Can you explain these concepts with the examples given?

<?  Php
 class A {
 private static $sfoo = 1;
 private $ifoo = 2;
 bracket
 $cl1 = static function() {
 return A::$sfoo;
 };
 $cl2 = function() {
 return $this->ifoo;
 };
 
 $bcl1 = Closure::bind($cl1, null, 'A');
 $bcl2 = Closure::bind($cl2, new A(), 'A');
 echo $bcl1(), "\n";
 echo $bcl2(), "\n";
 ?  >

Thank you

I wonder if you have used itJshit the targetCallOr ..Apply, a bit similar.

In fact, closure is regarded as a member method or a static member method of an object.

Closure::bind($cl1, null, 'A');  //is equivalent to adding a static member method to the class
 Closure::bind($cl2, new A(), 'A');  //Equivalent to adding a member method to the class

Used in member methods$thisAccessing Objects, Static Member Methods Directly UsedClass Name:: MemberThe method of.
However, because it is Anonymous function and has no function name, it returns a closure bound to the scope of the $this object and class for your use.