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

  • SEARCH
  • Home
  • 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 7487857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:40:27+00:00 2026-05-29T14:40:27+00:00

So, I am starting to gasp the concept of abstract and interface in PHP.

  • 0

So, I am starting to gasp the concept of abstract and interface in PHP.
But when is it really ever useful?

Sure I can with an interface make up the rules for my classes, so they all follow a specific pattern. But when is it really useful?

And why should I make an abstract class instead of just making a class that works by it own but is useful for other classes.
Abstract I perhaps can put my head around and see a good use, for example by making a general class. Like making a abstract Database class, then extending it onto a Mysql- and a MsAccess database class. Giving both similar functions to work with, allowing seamless experience in both cases.

But really, could anyone give me a better example of when abstract and interface are really useful?
And please note, I do know how it works, or how to write the code, just not how or when to use it.

Thanks!

  • 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-29T14:40:29+00:00Added an answer on May 29, 2026 at 2:40 pm

    An interface is not a class, while an abstract class is already a class.

    As every class has an interface (by definition), the interface allows you to specify an interface next to any class, be it abstract or not.

    Programming against interfaces then allows you to replace one class with another one while keeping the same interface. So it makes your code less coupled. It’s not programmed against concrete classes any longer but “only” against more lightweight interfaces. An interface then is useful if you don’t want to program against concrete class names but against types. You can replace an object then with any other object that implements the same interface.

    An abstract class on the other hand – even called abstract – is pretty concrete. However, it’s not final, so it forms a pattern of a class, like a specification how a class that extends from it should be written for a certain functionality. As it’s abstract, it can’t come to live without extending from it. Abstract classes are used to create base classes with code that will be used more than once to reduce code duplication and not being able to instantiate directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Starting to learn Canvas and have two classes so far (main one to call
Starting with a list of objects containing two parameters notional and currency, how can
Starting a project, and this irriating me. I think the code is okay, but
Starting a new project in Xcode 4 - what's the best way to make
Starting with version 5.3, PHP supports late binding for static methods. While it's an
Starting a new GWT application and wondering if I can get some advice from
Starting with 2 png files on disk (which I can load to 2 pixmaps)
Starting to get my head around makefiles for my C programs, but having some
Starting with this code: new Person(ET).WithAge(88) How can it be refactored to: new Person(ET,
Starting with API level 9, there's android:filterTouchesWhenObscured attribute and corresponding setFilterTouchesWhenObscured method on ViewGroup

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.