Concept of Abstraction in PHP
Concept of Abstraction in PHP is important php oop (object oriented programming) concept.
To show the needed/relevant information or details without showing all information which is not necessary is called abstraction.
Abstraction focus only what the object does instead of how.
Consider a very simple example in mathematics world - mulitplication. If we have two variables 'x' and 'y' then we simply say their multiplication without knowing what happening behind the scenes it means how variable value are stored in memory, how variable value convert in binary format, how processor processes the multiplication information.
Other example of Mobile Phone, mobile phones are common and as i know everyone are using mobile phone but they mostly know about their external feature like display screen and keypad buttons to dial a number, camera instead of what it does internally.
- abstract class MobilePhone
- {
- public Calling();
- public SendSMS();
- }
- public class Nokia1400 extends MobilePhone
- {
- }
- public class Nokia2700 extends MobilePhone
- {
- public FMRadio();
- public MP3();
- public Camera();
- }
- public class BlackBerry extends MobilePhone
- {
- public FMRadio();
- public MP3();
- public Camera();
- public Recording();
- public ReadAndSendEmails();
- }
abstract class MobilePhone{public Calling(); // calling functionpublic SendSMS(); // calling function}public class Nokia1400 extends MobilePhone{// code here for Nokia 1400 class}public class Nokia2700 extends MobilePhone{public FMRadio(); // calling functionpublic MP3(); // calling functionpublic Camera(); // calling function}public class BlackBerry extends MobilePhone{public FMRadio(); // calling functionpublic MP3(); // calling functionpublic Camera(); // calling functionpublic Recording(); // calling functionpublic ReadAndSendEmails(); // calling function}