The magic method _ call () ,__ clone () ,__ set () ,__ get () in php (). Magic methods in php _ call () ,__ clone () ,__ set () ,__ get () _ call ($ a, $ v ), when the external call class does not exist or is invisible (using protected, private modification), the magic method _ call () ,__ clone () in php is automatically called (), __set () ,__ get ()
_ Call ($ a, $ v): when a method that does not exist or is invisible in an external call class of the class (modified using protected or private, the _ call (method name, array parameter) is automatically called. two parameters are passed to the modified method. The first parameter is the name of the called method, the second is to put the passed parameters into the array. The _ clone () method is triggered when the class object is cloned. _ Set ($ key, $ val) triggers this method when the class does not exist or is invisible (protected, private modifier) in the external setting class of the class. at this time, two parameters are passed, the first is the attribute name, and the second is the attribute value. _ Get ($ key) triggers this method when the class does not exist or is invisible (protected, private modifier) in the external get class. at this time, one parameter is passed, that is, the attribute name. Example:
";} Public function _ call ($ name, $ arg) {echo" someone wants to call a nonexistent or invisible method name ", $ name ,", the first parameter is $ arg [0].
";} Public function _ set ($ k, $ v) {echo" someone wants to set a property that does not exist or is invisible ", $ k," the value is ", $ v ,"
";}Public function _ get ($ k) {echo" someone wants to get a nonexistent or invisible property ", $ k ;}}
$ Test1 = new test ();
$ Test3 = $ test1; // at this time, $ test3 and $ test1 are the same object, that is, they all point to the same object.
$ Test2 = clone $ test1; // after cloning, $ test1 and $ test2 are two different objects, although the stored values are the same
$ Test1-> abc (1, 2, 3 );
$ Test1-> a = 3;
$ Test1-> B;
Round () ,__ clone () ,__ set () ,__ get () _ call ($ a, $ v ), when the method does not exist or is invisible in the external call class of the class (modified with protected and private), it is automatically called...