Sandman wrote:
I have a master-script that runs for every site I make, and it has a
standard set of functions, but sometimes I would want to override
that function for a particular site, but if I redefine it for that
site, PHP will complain about overriding functions. Since that's a
good warning, I wouldn't want to remove it, but I would want to
"undefine" a function before defining it again.
like: function_undefine("drawbox");
Or something like that.
Anyone got any suggestions?
One suggestion is to use objects. Specifically, you could turn your
"master-script" into a class, and then instantiate your sites as children of
the class, something like:
<? /* master-class.php */
class BigKahuna {
/* here go functions */
function OneBigFatMasterFunction() {
}
}
?>
<? /* the_site.php */
require_once("master-class.php");
class TheSite extends BigKahuna {
function TheSite() {
/* this is the constructor function, that gets executed every time
you
instantiate the class
*/
}
function OneBigFatMasterFunction() {
/* this overrides the function above */
}
}
?>
<? /* index.php for the site */
require_once('the_site.php');
$site = new TheSite();
?>
That's all, except that instead of calling the functions defined in the two
class the usual way, you call them as $this->OneBigFatMasterFunction().
Berislav
--
If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.