Is it possible in PHP to instantiate an object from the name of a class, if the class name is stored in a string?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Do the Java Integer and Double objects have unnece
- Can php detect if javascript is on or not?
Static too:
Yep, definitely.
Yes it is:
You can do some dynamic invocation by storing your classname(s) / methods in a storage such as a database. Assuming that the class is resilient for errors.
etc.. Then in your code using the strings returned by the database for classes and methods names. you can even store sql queries for your classes, the level of automation if up to your imagination.
I use this method to create REST web services.