is it possible to make a callback on a static class method (php 4.1.0)? any idea why the following code does not work?
class Test { function writeTest() { echo('object test'); } } function writeTest() { echo('test'); } function doCallback( $func ) { $func(); } doCallback('writeTest'); // works Test::writeTest(); // works doCallback('Test::writeTest'); // doesn't work
While I don't have an answer as to why it isn't working, here is a work around:
function doCallback( $func ) {
if(strstr($func,'::')) { $parts = explode('::',$func); call_user_func($parts); } else { $func(); }
}
works fine. thanks :-)