note 67906 deleted from language.oop5.basic by bjori
| From: | bjori@php.net | Date: | Thu, 06 Jul 2006 11:18:15 +0000 |
| Subject: | note 67906 deleted from language.oop5.basic by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114502@lists.php.net to get a copy of this message | ||
Note Submitter: jonas dot stensved at playbackmedia dot se
Reason: 5
----
If you have to declare a class in runtime and be able to use various types (in my case they where
sharing an interface) by just knowing the name of the class you can do like this:
<?php
class foo
{
public $bar = "hest";
}
$className = "foo";
$instance = new $className();
var_dump($instance);
?>
I had a lot use of this in a complex plugin-based managment system.
Jonas