Jump to content

Extends in php


ngreenwood6

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.