In perl, you can define an "AUTOLOAD" routine which intercepts any call to a non-existant function, for example, if you're building an API into your perl application so that others could drop in programming code to be dynamically executed without altering the program itself, you might include the following:
sub AUTOLOAD {
return "<!-- No subroutine by the name $AUTOLOAD -->";
}
The reason for doing such could be any number of things, the least of which might be to gracefully handle calls to non-existant subroutines (typos) by the third party programmer when your program tries to run his code.
Does PHP have any similar mechanisms?
I'm currently planning for an API on a large PHP project I'm developing so that additional functions could be dropped into the program without altering the original program, and in effect triggered dynamically through references to them in program output templates, settings, or otherwise.
This is not a concern regarding an error in the third party programming dropped in using the API, but rather the fact that users have to dynamically trigger these third party functions via templates or settings, and the potential for an end user to enter an incorrect function name, typo, wrong casing, or any other imaginable typical input other then what is expected would essentially cause the program to puke all over itself.
I can handle bad code in third party modules gracefully with eval's and suppose I could always wrap the dynamic call to a function in an eval as well, however, if I had a way to intercept calls to non-existant functions, that would be favorable (and as far as I can tell, trigger_error does not intercept a call to a non existant function).
Thanks in advance.
Scott A. Hammond, Sr., CEO
Prima Internet, Inc.