There is actually one way how you can call common methods from multiple classes. It's bit of a hack but works, though I don't recommend to use it because it's not documented feature.
InterestingPHP Code:class Common{
protected $property = '';
function commonMethod(){
$this->property = 'test';
}
}
class SomeClass{
function commonMethod(){
Common::commonMethod();
}
}
class SomeOtherClass{
function commonMethod(){
Common::commonMethod();
}
}
$obj = new SomeClass();
$obj->commonMethod();
$obj2 = new SomeOtherClass();
$obj2->commonMethod();
/* output
SomeClass Object
(
[property] => test
)
SomeOtherClass Object
(
[property] => test
)
*/
Just spotted this from http://fi2.php.net/manual/en/language.oop5.php



Just spotted this from


Bookmarks