note 46327 deleted from function.call-user-func by cmb
| From: | cmb@php.net | Date: | Sun, 08 Dec 2019 11:13:51 +0000 |
| Subject: | note 46327 deleted from function.call-user-func by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213447@lists.php.net to get a copy of this message | ||
Note Submitter:
----
If you are trying to instantiate an object from a class whose name is dynamic, you WILL NOT be able
to do this with call_user_func() and I do not suggest that you do it with eval(). The way to do it
is actually much simpler than i thought. As far as i know this works in PHP 4 and 5:
<?PHP
class foo {
var $boo;
function foo( $someVal ) {
$this->boo = $someVal;
}
}
$ClassToUse = "foo";
$bar = new $ClassToUse('test');
echo $bar->boo;
?>