note 46327 added to function.call-user-func

From: Date: Thu, 07 Oct 2004 07:23:03 +0000
Subject: note 46327 added to function.call-user-func
Groups: php.notes 
Request: Send a blank email to php-notes+get-78114@lists.php.net to get a copy of this message
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; ?> ---- Manual Page -- http://www.php.net/manual/en/function.call-user-func.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46327 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46327&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46327&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78114) next »