tonelm54
asked on
Does class function exist
I'm trying to write a simple function in a class which will display debug information if the function doesn't exist. However I don't know how to specify $this->myfunction name. What I've been working on is:-
Any ideas how I should be testing function_exists for a class?
Thank you
<?php
class pageHandler {
function showMain($arrayData) {
}
function callFunction($functionName, $arrayData) {
if (function_exists($functionName)) {
call_user_func(array($this, $functionName),$arrayData);
} else {
echo "Function $functionName not yet declared<br/>" . print_r($arrayData,true);
}
}
}
$newTest = new pageHandler();
$newTest->callFunction("showMain",array('para1'=>'val1', 'para2'=>'val2'));
?>
Any ideas how I should be testing function_exists for a class?
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeah, I've had projects like that, too! Best of luck with it, ~Ray
ASKER
I know usually I could get the IDE to display the error saying "function not declared", however as it will be multiple programs all feeding in (some I've got no documentation on) I wanted to simply my debugging