Skip to main content

How to get class by name in PHP?

I have the string with class name. I want to get a class with this name and call a static methods of this class.

How to make something like this?


$className = "Model";
getClassByName($className)::sayHello();


source https://stackoverflow.com/questions/69337315/how-to-get-class-by-name-in-php

Comments