Provides various official and user-released code samples for reference. You are welcome to exchange and learn * dynamic instantiation Class Libraries
* Original $ page = new \ Common \ Api \ Page ('A', 'B ');
* Now you only need $ page = Api ('page', 'A', 'B ')
/**
* Call the api to instantiate the class library.
* Original $ page = new \ Common \ Api \ Page ('A', 'B ');
* Now you only need $ page = Api ('page', 'A', 'B ')
* @ Param $ class_name Class Name
* @ Param $ param1 parameter 1
* @ Author: temper
*/
Function Api (){
$ Args = func_get_args ();
$ Class_name = array_shift ($ args );
$ Class = strpos ($ class_name ,'\\')? $ Class_name: 'common \ Api \ '. ucwords (strtolower ($ class_name ));
$ Class_example = new ReflectionClass ($ class );
Return $ class_example-> newInstanceArgs ($ args );
}-----------
April July 9:
Do not use it. You cannot determine whether the _ construct method exists in the class, leading to errors.
I did not expect how to solve this problem for the moment.
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB