Quote:
Originally Posted by Jaxel
I also personally feel that using checks like "function_exists()" is a big mistake. I think a program should either DEGRADE gracefully and silently without the user knowing, or FAIL as loud as possible. If you start using "function_exists()", the program doesn't degrade as it should, it instead FAILS, but it doesn't tell anybody it fails; no one knows it failed until things just don't work as it should. Error messages are there for a reason, to inform you that there was an error.
|
No offence, but I must disagree quite strongly with this.
Wrapping function_exists() around your function declaration (which I have already empirically proven
will cause errors in specific scenarios through no fault in anybody's code) simply means that if the function exists, the code will continue to work 100% as intended with no degradation or ill effects whatsoever.
The only specific scenario where having a re-declare message would be beneficial is if two mods attempted to use the same function name, which should never happen because all mods should name their functions in such a way that it's uniquely tied to their mod.
So yeah, I don't find a single reason why a function declaration that's happening in a place that may very well be executed multiple times should not be wrapped in function_exists().
Alternatively, it would be possible to put the function declaration in a file of its own, and then use require_once().
It'd have the same effect, more or less
Fillip