First of all: Do not do this.
That said, if you really need to "refedine" a class, you can use a wrapper class to do so
<?php
class foo { //Original definition here };
class bar {
var $baseobj;
function bar($some, $args) {
$this->baseobj=new $which($some, $args);
}
function someMethod() {
return $this->baseobj->someMthod();
}
//...
}
class baz {
function someMethod() {
return "This is the result";
}
//...
}
$obj=new bar($this, $that);
//$obj is now a wrapped foo object
echo $obj->someMethod(); //Will call into foo
$obj->baseobj=new baz($this, $that);
//$obj is now a wrapped baz object
echo $obj->someMethod(); //Will call into baz
?>
Again: Do not do this without a very, very good reason!
Disclaimer: This implementation is more than crude, it is only ment to transport the idea.