are.ehibou.com

September 12, 2008

anonymous, dynamic, variable classes and methods

Filed under: Side Notes,php — Tags: — admin @ 2:53 pm

To call a method by dynamic name you can do this:

$methodName="MyMethod";
$result=$methodName();

To create a class by dynamic name you can do this:

$className="MyClass";
$classVar=new $className;

To call any method by dynamic name in previously initialized class you can do this:

$methodName="MyMethod";
$result=$classVar->$methodName();
  • Share/Bookmark

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress