Examples of PHP dynamically generated objects based on string class names in previous articles we introduce PHP to dynamically generate objects based on string names, so what we've introduced today is similar to the one in the previous section, and PHP uses the name of the string to invoke the idea of the class!
First step: First download the PHP we need for this lesson to use the name of the string to invoke the class library: http://www.php.cn/xiazai/leiku/605
Step two: Find the PHP class library file after download, unzip to the local directory, then create a new file ~
The third step: we call this class in the new PHP file, and instantiate:
<?phpinclude_once "stringdiaoyong.php"; Introduce class file $game = new game (); Instantiate column//Method 1, using Call_user_func call_user_func (Array ($game, ' play '), 1),//Method 2$game->{' Play '} (2);//or $method = ' Play '; $game-$method (3);? >
The results of the final operation are as follows: