Before we answer this question, you must have a clear definition of what exactly is an abstract class, an abstract method and a static method.
Abstract Class: In the Object-Oriented programming paradigm, abstraction refers to the process of hiding the internal implementation details of any program and only showing the functionality of the program to the user. Abstract classes are a way of achieving this. An abstract class is any class that cannot be instantiated (i.e. objects cannot be created) and has to be extended (inherited) for objects to be created. The ‘abstract’ keyword is used to create abstract classes.
Abstract Method: An abstract method is a method that can only be declared and not defined. It is defined in the class that inherits from this class.
Static Method: A static method of any class is a method that is created only once. This means that even if you create hundreds of objects of a class with static methods, there will be the only copy of each static method.
Consider the following example:
Now if you run this PHP code, you will see the error, “PHP Fatal error: Cannot call abstract method Abstract_Parent::X().”
When we call method X() in the child class, the static function X() in the parent gets called. In the method X(), we are again calling function Y(), which is an abstract static function. The Y() that function X() is trying to call is the parent class Y(), which is itself an abstract function.
So, using abstract and static on the same method defeats each other purpose. This is the reason why PHP 5.2+ does not allow abstract static class methods.
- Abstract Methods in Java with Examples
- Why PHP script does not create a directory with 777 permissions ?
- Difference between static and non-static method in Java
- Difference between static and non-static variables in Java
- Understanding "static" in "public static void main" in Java
- Why does sizeof(x++) not increment x in C?
- Why does AngularJS include an empty option in select ?
- Why does canvas.toDataURL() throws a security exception?
- Why does password boxes are smaller than text boxes in IE ?
- Why does SASS cache folder is created ?
- Why Transition properties does not work with display properties ?
- Abstract Classes in PHP
- C# | Abstract Classes
- Abstract Classes in Python
- Scala | Abstract Type members
- Messages, aggregation and abstract classes in OOPS
- New self vs. new static in PHP
- Comparison between static and instance method in PHP
- Static Function in PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.