I would like to know if it's possible to create a magic object that extends another magic object, (with PHP).
Asked
Active
Viewed 1,790 times
3
-
Now where does the magic happen? – Gumbo Sep 26 '09 at 15:02
-
well the two classes are using magic methods http://us2.php.net/manual/en/language.oop5.magic.php – Roch Sep 26 '09 at 15:06
-
1@Sbm007 __get and __set are magic methods, they're called whenever you try to access a non-public member variable. – MattBelanger Sep 26 '09 at 16:37
-
What's the point in calling your getter/setter methods __get/__set... The 2 underscores are only used by PHP for magic methods such as toString, constructor and destructor in order to avoid any naming conflicts. – Waleed Amjad Sep 26 '09 at 16:38
1 Answers
7
I'm not totally sure what you're asking... are you wanting to explicitly invoke the magic methods of the parent class? If so, you can use the class' parent
reference:
class Object extends dbObj{
// ...
// this is what i'm assuming you're looking for:
public function __call($method, $variables){
return parent::__call($method, $variables);
}
}

brianreavis
- 11,562
- 3
- 43
- 50