tags:

views:

71

answers:

2

Hi What is abstract class in php ? where it can be used?

+1  A: 

An abstract class is a class that is only partially implemented by the programmer. It may contain one or more abstract methods. An abstract method is simply a function definition that serves to tell the programmer that the method must be implemented in a child class.

There is good explanation of that here.

Sarfraz
@Sarfraz I like your magic dialer by the way. Any chance that will work in Germany?
Pekka
@Pekka i'm pretty sure you will have your sim card autolocked after n false tries.
Gordon
@Gordon crap. I was so hoping to finally get rid of my 2-year contract shackles :) I like how that article was dated *March 27th* :)
Pekka
@Pekka: Thanks for liking it, yes it should work anywhere with small modification.
Sarfraz
@Gordon: That's true, but one can avoid it by not making too may attempts and for that you need to use a sim card specifically for that purpose. These policies may be different in various countries.
Sarfraz
+1  A: 

An abstract class is a class that contains at least one abstract method, which is a method without any actual code in it, just the name and the parameters, and that has been marked as "abstract".

The purpose of this is to provide a kind of template to inherit from and to force the inheriting class to implement the abstract methods.

An abstract class thus is something between a regular class and a pure interface. Also interfaces are a special case of abstract classes where ALL methods are abstract.

See this section of the PHP manual for further reference.

Techpriester