{"id":9422,"date":"2021-10-06T06:20:14","date_gmt":"2021-10-06T06:20:14","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=9422"},"modified":"2021-10-07T11:33:50","modified_gmt":"2021-10-07T11:33:50","slug":"php-inheritance","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/","title":{"rendered":"PHP OOP : Inheritance"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">What is inheritance in php?<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Inheritance is properties of PHP.<\/li><li>Accessing the feature of one class of another class.<\/li><li>Three types that is single, multiple and multilevel inheritance.<\/li><li>It is the four pillars of oops.<\/li><li>It allows a class to reuse the code from another class without duplicating it.<\/li><li>Two classes one is base\/main another one is derived class.<\/li><li>Base class only use its own function but in Derived class it use both function base or derived class.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How to use inheritance in php?<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass school {\n}\nclass students extends school {\n}\n$sch =new school (); \/\/ only use class school \n$stu = new students (); \/\/ use both class school students (properties and methods)\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Example of main\/base class use :-<\/h3>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vikash-cotocus\/1f7b68919052d8717b7ca3b533760172.js\"><\/script>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"523\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-1024x523.png\" alt=\"\" class=\"wp-image-9424\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-1024x523.png 1024w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-300x153.png 300w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-768x392.png 768w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-1536x784.png 1536w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3.png 1638w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example of inheritance:<\/h3>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vikash-cotocus\/2ff225a54be4148e3799012c82393c72.js\"><\/script>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"607\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php4-1024x607.png\" alt=\"\" class=\"wp-image-9428\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php4-1024x607.png 1024w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php4-300x178.png 300w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php4-768x455.png 768w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php4.png 1520w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>What is inheritance in php? Inheritance is properties of PHP. Accessing the feature of one class of another class. Three [&hellip;]<\/p>\n","protected":false},"author":34,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5388],"tags":[6890,6889,1122,545,6888,373,177,6886,593,1371,6885,4552,213,670,6887],"class_list":["post-9422","post","type-post","status-publish","format-standard","hentry","category-php","tag-example-of-inheritance-in-php","tag-explain-main-and-derived-class","tag-guide","tag-how","tag-how-to-use-inheritance-in-php","tag-perforce","tag-php","tag-php-inheritance","tag-process","tag-scmgalaxy-devops-training-online","tag-scmgalaxy-php","tag-scmgalaxy-tutorials","tag-tutorial","tag-what","tag-what-is-inheritance-in-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP OOP : Inheritance - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP OOP : Inheritance - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"What is inheritance in php? Inheritance is properties of PHP. Accessing the feature of one class of another class. Three [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-06T06:20:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-07T11:33:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-1024x523.png\" \/>\n<meta name=\"author\" content=\"vikashdev k\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"vikashdev k\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/\"},\"author\":{\"name\":\"vikashdev k\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\"},\"headline\":\"PHP OOP : Inheritance\",\"datePublished\":\"2021-10-06T06:20:14+00:00\",\"dateModified\":\"2021-10-07T11:33:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/\"},\"wordCount\":98,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/php3-1024x523.png\",\"keywords\":[\"example of inheritance in php\",\"explain main and derived class\",\"Guide\",\"How\",\"how to use inheritance in php\",\"Perforce\",\"Php\",\"php inheritance\",\"Process\",\"scmGalaxy DevOps Training Online\",\"scmgalaxy php\",\"scmGalaxy Tutorials\",\"Tutorial\",\"What\",\"what is inheritance in php\"],\"articleSection\":[\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/\",\"name\":\"PHP OOP : Inheritance - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/php3-1024x523.png\",\"datePublished\":\"2021-10-06T06:20:14+00:00\",\"dateModified\":\"2021-10-07T11:33:50+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/php3.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/10\\\/php3.png\",\"width\":1638,\"height\":836},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/php-inheritance\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP OOP : Inheritance\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\",\"name\":\"vikashdev k\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"caption\":\"vikashdev k\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/vikashdev\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP OOP : Inheritance - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/","og_locale":"en_US","og_type":"article","og_title":"PHP OOP : Inheritance - scmGalaxy","og_description":"What is inheritance in php? Inheritance is properties of PHP. Accessing the feature of one class of another class. Three [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/","og_site_name":"scmGalaxy","article_published_time":"2021-10-06T06:20:14+00:00","article_modified_time":"2021-10-07T11:33:50+00:00","og_image":[{"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-1024x523.png","type":"","width":"","height":""}],"author":"vikashdev k","twitter_card":"summary_large_image","twitter_misc":{"Written by":"vikashdev k","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/"},"author":{"name":"vikashdev k","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515"},"headline":"PHP OOP : Inheritance","datePublished":"2021-10-06T06:20:14+00:00","dateModified":"2021-10-07T11:33:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/"},"wordCount":98,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-1024x523.png","keywords":["example of inheritance in php","explain main and derived class","Guide","How","how to use inheritance in php","Perforce","Php","php inheritance","Process","scmGalaxy DevOps Training Online","scmgalaxy php","scmGalaxy Tutorials","Tutorial","What","what is inheritance in php"],"articleSection":["php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/","name":"PHP OOP : Inheritance - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3-1024x523.png","datePublished":"2021-10-06T06:20:14+00:00","dateModified":"2021-10-07T11:33:50+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/10\/php3.png","width":1638,"height":836},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/php-inheritance\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"PHP OOP : Inheritance"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515","name":"vikashdev k","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","caption":"vikashdev k"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/vikashdev\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/9422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=9422"}],"version-history":[{"count":3,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/9422\/revisions"}],"predecessor-version":[{"id":9455,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/9422\/revisions\/9455"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=9422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=9422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=9422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}