ngreenwood6 Posted January 30, 2011 Share Posted January 30, 2011 I was wondering if there was a class that I could extend that extends the main class in php. For example all of the classes that I am creating will extend the core class or will be extending a class that extends from the core class. However if the class doesnt exist then it will throw an error. What I would like to do is be able to handle this error instead of just throwing the error so I was hoping that there was a class that I could extend the core class from to handle these errors. This way I can use the magic method __get() to handle the error. If there is another way to go about this please let me know so that I can look into that solution. Link to comment https://forums.phpfreaks.com/topic/226110-extends-in-php/ Share on other sites More sharing options...
jcbones Posted January 30, 2011 Share Posted January 30, 2011 I would use __autoload() in your situation. That would only work if the extended class of the core class doesn't have an error. If the extended class of the core class has a child class that reverts back to the extended class within a child class of the core class, none of these functions will work. Then you would have to us __toString(). Link to comment https://forums.phpfreaks.com/topic/226110-extends-in-php/#findComment-1167230 Share on other sites More sharing options...
trq Posted January 30, 2011 Share Posted January 30, 2011 For example all of the classes that I am creating will extend the core class or will be extending a class that extends from the core class. That sounds like a terrible idea. Why would *all* your classes be of the same type? Link to comment https://forums.phpfreaks.com/topic/226110-extends-in-php/#findComment-1167268 Share on other sites More sharing options...
jcbones Posted January 30, 2011 Share Posted January 30, 2011 For example all of the classes that I am creating will extend the core class or will be extending a class that extends from the core class. That sounds like a terrible idea. Why would *all* your classes be of the same type? I'm sorry, I took this post as satire. Link to comment https://forums.phpfreaks.com/topic/226110-extends-in-php/#findComment-1167417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.