Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3679154
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:25:34+00:00 2026-05-19T03:25:34+00:00

I am trying to improve my knowledge of OOP in PHP and have been

  • 0

I am trying to improve my knowledge of OOP in PHP and have been researching abstract classes and interfaces.

What I have learned

  • They are both classes that cannot be instantiated themselves but can olny be extended (implemented in the case of interfaces)
  • Abstract classes provide methods and properties for other classes that extend them.
  • If a class uses an abstract method then the class itself must also be abstract.
  • If an abstract method is defined within an abstract class, all child classes must define the details of that method. Methods not defined as abstract can be used in the same way as normal methods.
  • Interfaces define what methods a class that implements it must have. The functionality of the methods are not defined in the interface, the interface just offers a list of methods that must be included in the child class.
  • An interface does not define any properties.
  • Classes can implement as many interfaces as they want to but they must define a method for every one of the interfaces they implement

I think that covers the basics. Please feel free to add to that if you think there’s anything I have missed.

What I would like to know is if there are any real world examples of implementation of these classes, especially the interface class. Does anyone know of any open source applications that use them that I can browse to better understand them and see where and when they are used effectively? I have come across book examples which use animals which fails to demonstrate the importance of these classes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:25:34+00:00Added an answer on May 19, 2026 at 3:25 am

    Not a real world example as such, but one Design Pattern where you usually encounter interfaces and abstract classes is the Command Pattern. See link for example code.

    In general, “programming against an interface” is considered good OO practise, because it decouples concrete implementations and let you more easily change them for other implementations, e.g. instead of asking for a specific class

    public function fn(ConcreteClass $obj)
    {
        $obj->doSomething()
    }
    

    you just ask that it provides a certain set of methods

    public function fn(MyInterface $obj)
    {
        $obj->doSomething()
    }
    

    Interfaces also help teasing apart large inheritance structures. Because PHP supports only Single Inheritance, you’ll often see hierarchies like this:

    BaseClass -> Logger -> Auth -> User
    

    where each of these contains specific aspects used inside these classes. With an interface, you just do

    User implements Loggable, Authenticable
    

    and then include that specific code via Strategy Patterns or Composition/Aggregation, which is ultimately much more maintainable.

    For a list of predefined interfaces in PHP see my answer to:

    • where to find "template" interfaces?.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to improve my jQuery skill and I have this bit of
I've been trying to improve the build times for my product. We're using continuous
I'm trying to improve performance in a torrent tracker site . But I've been
I am trying to improve my knowledge on program architecture and recently arised a
Hello I'm trying to improve my ruby knowledge by reading The Ruby Programming Language
I trying to improve a textbox that filters a gridview, by implementing an enhanced
I am trying to use the data I have received from a php script,
I've been trying to improve performance our app. The worst performing area seems to
Im am trying to improve a ToDo app for the iPhone. I have two
I am trying to improve my C++ by creating a program that will take

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.