compare class and interface in php

It is for static page, dynamic page, website, SEO, performance and other web development discussion
Joshi jahanvi

compare class and interface in php

Postby Joshi jahanvi » Thu Oct 30, 2014 2:15 pm

In PHP what is the difference between a Class and an Interface?

sonall gajera

Re: compare class and interface in php

Postby sonall gajera » Thu Jul 09, 2015 11:15 am


1.For abstract class a method must be declared as abstract. 1.For interface all the methods by default are abstract methods only.
Abstract methods doesn’t have any implementation. So one cannot declare variables or concrete methods in interfaces.

2.Abstract class can contain variables and concrete methods. 2.Interfaces cannot contain variables and concrete methods except constants.

3.A class can Inherit only one Abstract class and Multiple 3.A class can implement many interfaces and Multiple interface inheritance is possible.
inheritance is not possible for Abstract class.

Return to “PHP, HTML, MYSQL and Web Hosting”

Who is online

Users browsing this forum: No registered users and 2 guests