{"id":10641,"date":"2020-02-17T13:08:49","date_gmt":"2020-02-17T13:08:49","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=10641"},"modified":"2022-05-08T12:07:19","modified_gmt":"2022-05-08T12:07:19","slug":"inheritance-in-php-with-example","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/inheritance-in-php-with-example\/","title":{"rendered":"How to declare Inheritance in PHP with example?"},"content":{"rendered":"\n<p><strong>What is Inheritance?<\/strong>:-<br> Inheritance means one class method or properties access to another class. The child class will inherit all public, private, protected methods or properties from the parent class.<\/p>\n\n\n\n<p><strong>Public Access Modifier:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/07688560cd4f2a48acc7c327237b5939.js\"><\/script>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/public-access-modifier.png\" alt=\"\" class=\"wp-image-10661\" width=\"254\" height=\"106\"\/><figcaption>Output<\/figcaption><\/figure>\n\n\n\n<p><strong>Private Access Modifier:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/3addfd31d180bdd0561a7d567ab8b12c.js\"><\/script>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"309\" height=\"50\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/private-access-modifier.png\" alt=\"\" class=\"wp-image-10662\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/private-access-modifier.png 309w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/private-access-modifier-300x49.png 300w\" sizes=\"auto, (max-width: 309px) 100vw, 309px\" \/><figcaption>Output<\/figcaption><\/figure>\n\n\n\n<p><strong>Protected Access modifier<\/strong> :-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/b8ab7b033185a5d10fbe98779d79e3af.js\"><\/script>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"329\" height=\"36\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/protected-access-modifier.png\" alt=\"\" class=\"wp-image-10663\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/protected-access-modifier.png 329w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/protected-access-modifier-300x33.png 300w\" sizes=\"auto, (max-width: 329px) 100vw, 329px\" \/><figcaption>Output<\/figcaption><\/figure>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_64630\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_80832\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_64630\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>What is Inheritance?:- Inheritance means one class method or properties access to another class. The child class will inherit all public, private, protected methods or properties from the parent class. Public Access Modifier:- Private Access Modifier:- Protected Access modifier :-<\/p>\n","protected":false},"author":1,"featured_media":10678,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5150],"tags":[380,519,5925,5926,177,5923,5924,5137],"class_list":["post-10641","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-access","tag-example","tag-inheritance","tag-modifier","tag-php","tag-private","tag-protected","tag-public"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=10641"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10641\/revisions"}],"predecessor-version":[{"id":24942,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10641\/revisions\/24942"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/10678"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=10641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=10641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=10641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}