{"id":802,"date":"2018-11-14T16:14:12","date_gmt":"2018-11-14T16:14:12","guid":{"rendered":"https:\/\/barkhane.com\/php\/2018\/11\/14\/data-abstraction-in-php\/"},"modified":"2024-03-03T14:56:10","modified_gmt":"2024-03-03T14:56:10","slug":"data-abstraction-in-php","status":"publish","type":"post","link":"https:\/\/barkhane.com\/php\/data-abstraction-in-php\/","title":{"rendered":"Data Abstraction in PHP"},"content":{"rendered":"<p>Data Abstraction in PHP<\/p>\n<p>Abstraction provides you a generalized view of your <a href=\"https:\/\/barkhane.com\/php\/abstract-classes-in-php\/\">classes<\/a> or <a href=\"https:\/\/barkhane.com\/php\/object-in-php\/\">object<\/a> by providing relevant information.<br \/>\nAbstraction is the process of hiding the working style of an object, and showing the information of an object in understandable manner.<br \/>\n<strong>I am giving real life Example of Abstraction:<\/strong><\/p>\n<p>Suppose you have an object Mobile Phone.<br \/>\nSuppose you have 3 mobile phones as following<\/p>\n<p>Nokia 1400 (Features- Calling, SMS)<br \/>\nNokia 2700 (Features- Calling, SMS, FM Radio, MP3, Camera)<br \/>\nBlack Berry (Features- Calling, SMS, FM Radio, MP3, Camera, Video Recording, Reading E-mails)<\/p>\n<p>Abstract information (Necessary and Common Information) for the object \u201cMobile Phone\u201d is make a call to any number and can send SMS.\u201d<br \/>\nso that, for mobile phone object you will have abstract class like following:-<\/p>\n<div id=\"geshisourcecolorer-1025b7b74dc8ed32c98efad9213ce2fd\" class=\"php geshisourcecolorer geshisourcecolorer-block-default\">\n<div class=\"head\"><\/div>\n<pre><code>\nabstract\u00a0class\u00a0MobilePhone\n{\npublic\u00a0Calling();\u00a0\/\/ calling function\npublic\u00a0SendSMS();\u00a0\/\/ calling function\n}\n\npublic\u00a0class\u00a0Nokia1400\u00a0extends\u00a0MobilePhone\n{\n\/\/ code here for Nokia 1400 class\n}\n\npublic\u00a0class\u00a0Nokia2700\u00a0extends\u00a0MobilePhone\n{\npublic\u00a0FMRadio();\u00a0\/\/ calling function\npublic\u00a0MP3();\u00a0\/\/ calling function\npublic\u00a0Camera();\u00a0\/\/ calling function\n}\n\npublic\u00a0class\u00a0BlackBerry\u00a0extends\u00a0MobilePhone\n{\npublic\u00a0FMRadio();\u00a0\/\/ calling function\npublic\u00a0MP3();\u00a0\/\/ calling function\npublic\u00a0Camera();\u00a0\/\/ calling function\npublic\u00a0Recording();\u00a0\/\/ calling function\npublic\u00a0ReadAndSendEmails();\u00a0\/\/ calling function\n\n}<\/code><\/pre>\n<\/div>\n<p>Data Abstraction in PHP means putting all the variables and methods in a class which are necessary.<br \/>\nFor example: \u2013 Abstract class and abstract method.<br \/>\nAbstraction is the common thing.<\/p>\n<p>Example:<br \/>\nIf somebody in your collage tell you to fill application form, you will fill your details like name, address, data of birth, which semester, percentage you have got etc.<\/p>\n<p>If some doctor gives you an application to fill the details, you will fill the details like name, address, date of birth, blood group, height and weight.<\/p>\n<p>See in the above example what is the common thing?<br \/>\nAge, name, address so you can create the class which consist of common thing that is called abstract class.<br \/>\nThat class is not complete and it can inherit by other class.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Data Abstraction in PHP Abstraction provides you a generalized view of your classes or object by providing relevant information. Abstraction [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[3],"tags":[],"class_list":["post-802","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts\/802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/comments?post=802"}],"version-history":[{"count":0,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts\/802\/revisions"}],"wp:attachment":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/media?parent=802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/categories?post=802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/tags?post=802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}