anonymous, dynamic, variable classes and methods

To call a method by dynamic name you can do this:
[code lang=”php”]
$methodName=”MyMethod”;
$result=$methodName();
[/code]
To create a class by dynamic name you can do this:
[code lang=”php”]
$className=”MyClass”;
$classVar=new $className;
[/code]
To call any method by dynamic name in previously initialized class you can do this:
[code lang=”php”]
$methodName=”MyMethod”;
$result=$classVar->$methodName();
[/code]

Leave a Reply