André Pletschette wrote:
Hi,
What do I have to do to call a function from $classname?
Like: $classname->test( );
<?php
// does $classname contain a name of a class? e.g:
class Test
{
function doIt() { echo "done it!\n"; }
}
$className = "Test";
$t = new $className;
$t->doIt();
// also look at the functions
// call_user_func() and call_user_func_array(),
// e.g:
call_user_func( array($className,"doIt") );
?>
BTW: I'm only using double-quotes when its really needed
because it makes testing the code in a linux shell 100 times
easier (when compared to using single-quotes).
AGAIN BTW: nobody understood your question so far because
'$classname->test();' is valid php syntax! (it just assumes
that $classname 'is' an object, not a string)
happy now? ;-)
Thankyou,
André
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php