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. Quote 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(). Quote 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? Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/226110-extends-in-php/#findComment-1167417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.