php / *** prototype mode ** Allow an object to create another customizable object, * Don't know how to create details, * Working principle is: Passing a prototype object to the creation of the original Object, * This object to be created is to copy them by requesting prototype objects to create ** @author doodoo
$ prototype = new prototype (); $ p2 = $ prototype-> copy ($ prot);
Print_R ($ prototype); Print_R ($ P2);
?>
In fact, PHP5 has a Clone function, so that our implementation is simple, the above code can be modified to
php / *** prototype mode ** Allow an object to create another customizable object, * Don't know how to create details, * Working principle is: Passing a prototype object to the creation of the original Object, * This object to be created is to copy them by requesting prototype objects to create ** @author doodoo
$ prototype = new prototype (); $ p2 = clone $ prototype;
Print_R ($ prototype); Print_R ($ P2);
?>
The use of prototype mode in PHP5 becomes the implementation of the use of Clone functions and the __clone () function.