{"id":545,"date":"2017-02-14T15:09:18","date_gmt":"2017-02-14T15:09:18","guid":{"rendered":"https:\/\/barkhane.com\/php\/2017\/02\/14\/access-specifier-php\/"},"modified":"2024-03-03T14:58:56","modified_gmt":"2024-03-03T14:58:56","slug":"access-specifier-php","status":"publish","type":"post","link":"https:\/\/barkhane.com\/php\/access-specifier-php\/","title":{"rendered":"Access Specifier in PHP"},"content":{"rendered":"<div class=\"code\">\n<h2>Access Specifier in\u00a0PHP<\/h2>\n<p>Access specifier in php is part of encapsulation. Encapsulation can be achieve with the help of access specifier. Access specifier specifies the level of the access of properties and methods.<\/p>\n<p>There are three <strong>Access Specifiers<\/strong> in PHP private, public protected. These keywords help you to define how methods and properties will be accessed by the user.<\/p>\n<\/div>\n<div class=\"code\">\n<ul>\n<li><strong>Private\u00a0<\/strong><\/li>\n<li><b>Public<\/b><\/li>\n<li><b>Protected<\/b><\/li>\n<\/ul>\n<h3><b>Private:<\/b><\/h3>\n<p>Private Data member and member function that declared as private are not allowed to be called from outside the <a href=\"https:\/\/barkhane.com\/php\/classes-in-php\/\">class<\/a>. However, you can easily access these properties within the class<\/p>\n<h3>Public :<\/h3>\n<p>Any Data member and member function that declared as public or without any modifier are allowed to access these properties from inside or outside the class.<\/p>\n<\/div>\n<h3><b>Protected: <\/b><\/h3>\n<p>It is a special type of modifier. If any property or method is declared as protected, you can only access these properties within the class and its subclass.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Access Specifier in\u00a0PHP Access specifier in php is part of encapsulation. Encapsulation can be achieve with the help of access [&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-545","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts\/545","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=545"}],"version-history":[{"count":0,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts\/545\/revisions"}],"wp:attachment":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/media?parent=545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/categories?post=545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/tags?post=545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}