I've seen some examples of similar things, but I can't find anything related to what I'm trying to do. Consider the case where you've got some large amount of mysql tables, and you want a function like 'myObject.tableName()' to get and print the information for that table.
Simplified a lot, I'd like to be able to do something akin to the following Javascript (sort of) code:
class SomeObject {
function SomeObject() {
this['nonExistantProperty'] = staticFunc;
this['nonExistantProperty']();
}
function staticFunc() {
trace( "Hello World" );
}
}
So here's the PHP code so far:
class SomeObject {
function SomeObject() {
$table = 'myTable';
$this->$table = &$this->staticFunc;
$this->$table();
}
function staticFunc() {
print( "Hello World" );
}
}
Obviously I would enclose the creation of the dynamic member function in a foreach loop for each table, etc. etc.
Does anyone have any ideas? I've tried a few different examples I've found, but does this just not work in PHP? Does $this->staticFunc not return a pointer to the function, and is there anyway to get a reference to staticFunc to assign it to another variable?