how to get a object according the name of class
-
how to implement like this:
$classname = "dsa";$ob = new $classname();
i just have a var of the class name and how to new the class?
You have the right syntax for doing that in your example. There are some helpful functions for working with classes: Class functions[^]. The class_exists[^] function is useful for checking if you have a valid class name.
-
how to implement like this:
$classname = "dsa";$ob = new $classname();
i just have a var of the class name and how to new the class?
Did u tried it yours before posting? That works for me: class A {} $classname = "A"; $obj = new $classname; if it is not your question then clear it.
-
You have the right syntax for doing that in your example. There are some helpful functions for working with classes: Class functions[^]. The class_exists[^] function is useful for checking if you have a valid class name.