Forum Moderators: coopster
I want to create a program which modifies 'foo()' function if a situation happens.
I don't want to insert an 'IF' within the function, since I want not to modify the original 'functions.php' file. But if I redeclare 'foo()' I get this error message:
-------
Cannot redeclare foo() (previously declared in /home/test/functions.php)
-------
How to redeclare the function? Thank you very much.
use override_function [php.net]
Hope this helps
Michal
redeclaring a function is a bit of a problem and really shouldn't be a first, or maybe even last, resort
just change the primary function and document it for upgrades, if it is in a software package that may need upgrading
your other option should be to change the return, use the function as is and deal with the returned data in a different way.
If your if is to make a single case for a specific use of the function then it goes against the whole idea of general multi use functions a bit