{"id":80,"date":"2022-10-15T04:44:58","date_gmt":"2022-10-15T04:44:58","guid":{"rendered":"https:\/\/devopssupport.in\/blog\/?p=80"},"modified":"2022-10-15T04:47:55","modified_gmt":"2022-10-15T04:47:55","slug":"inheritance-in-phpoops-concept","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/inheritance-in-phpoops-concept\/","title":{"rendered":"Inheritance in PHP(OOPS Concept)"},"content":{"rendered":"\n<p><strong>Inheritance<\/strong> :- When a class derives from another class. The child class will inherit all the public and protected properties and methods from the parent. An inherited class is defined by using the&nbsp;<code>extends<\/code>&nbsp;keyword.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>There are three type of Inheritance:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li><strong>Single inheritance<\/strong> &#8211;<\/li><\/ol>\n\n\n\n<p>Single inheritance supports php. In a single class can be derived by one class unique. We require to have two classes in between this method. One is the parent class and the other a child class itself.<\/p>\n\n\n\n<p>2. <strong><strong>Multilevel <\/strong> inheritance<\/strong>&nbsp;<\/p>\n\n\n\n<p>In this type of inheritance, there&nbsp;will be more than 2 classes involved. In Multilevel inheritance Parent class will be inherited by a child and then further child class will be inherited by another child class.<\/p>\n\n\n\n<p>3. <strong>Hierarchical inheritance<\/strong><\/p>\n\n\n\n<p>When more than one class inherit to a single class. This type of inheritance known as Hierarchical Inheritance<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/devopssupport.in\/blog\/wp-content\/uploads\/2022\/10\/download-2.jpeg\" alt=\"\" class=\"wp-image-87\" width=\"492\" height=\"295\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>SINGLE INHERITANCE<\/strong><\/p>\n\n\n\n<p>Ex:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;gist.github.com\/AvinashKumar33\/745e6e3769016a43ac7072b64dd388c0<\/code><\/pre>\n\n\n\n<p>Output:-<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"357\" height=\"310\" src=\"https:\/\/devopssupport.in\/blog\/wp-content\/uploads\/2022\/10\/Capture-3.jpg\" alt=\"\" class=\"wp-image-85\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2022\/10\/Capture-3.jpg 357w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2022\/10\/Capture-3-300x261.jpg 300w\" sizes=\"auto, (max-width: 357px) 100vw, 357px\" \/><\/figure>\n\n\n\n<p><strong><strong>Multilevel <\/strong> inheritance<\/strong>&nbsp;<\/p>\n\n\n\n<p>Ex:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;gist.github.com\/AvinashKumar33\/fdabd7b9d34f2d367c48d3fbb2ea72c8<\/code><\/pre>\n\n\n\n<p>Output:-<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"293\" height=\"100\" src=\"https:\/\/devopssupport.in\/blog\/wp-content\/uploads\/2022\/10\/Capture-4.jpg\" alt=\"\" class=\"wp-image-89\"\/><\/figure>\n\n\n\n<p><strong>Hierarchical inheritance<\/strong><\/p>\n\n\n\n<p>Ex:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;gist.github.com\/AvinashKumar33\/fd56b51f174a149e18067a62f9318b52<\/code><\/pre>\n\n\n\n<p>Output:-<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"265\" height=\"92\" src=\"https:\/\/devopssupport.in\/blog\/wp-content\/uploads\/2022\/10\/Capture-5.jpg\" alt=\"\" class=\"wp-image-90\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Inheritance :- When a class derives from another class. The child class will inherit all the public and protected properties and methods from the parent. An inherited&#8230; <\/p>\n","protected":false},"author":2,"featured_media":94,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":3,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions\/93"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media\/94"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}