Storing name of a member function of a class in a string
Posted: Wed Feb 27, 2008 9:11 am
Is there anyway to get this to work?
The global function setup2 can be invoked by storing its name inside the array. But how do I do the same for the member function setup1?
Any help will be appreciated!
Code: Select all
class cApplication
{
function __construct($initTask)
{
// debug
echo "<pre>";
print_r($initTask);
echo "</pre>";
foreach($initTask as $initFunction)
$initFunction();
}
}
// Testing Class
class test_application_framework
{
function test_init()
{
$initTask[] = 'test_application_framework::setup1';
$initTask[] = 'setup2';
$app = new cApplication($initTask);
}
function setup1()
{
echo "From inside test_application_framework<br>";
}
}
function setup2()
{
echo "from setup2<br>";
}
Any help will be appreciated!