{"id":231,"date":"2020-07-10T15:43:28","date_gmt":"2020-07-10T15:43:28","guid":{"rendered":"https:\/\/demo.wpartisan.net\/developmentsite\/what-is-the-difference-between-instance-and-object-in-php\/"},"modified":"2024-11-04T04:02:12","modified_gmt":"2024-11-04T04:02:12","slug":"what-is-the-difference-between-instance-and-object-in-php","status":"publish","type":"quick-tips","link":"https:\/\/demo.wpartisan.net\/developmentsite\/what-is-the-difference-between-instance-and-object-in-php\/","title":{"rendered":"What is the difference between Instance and Object in PHP?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Class is a \u201cblueprint\u201d that can use to \u201cinstantiate\u201d different \u201cobjects\u201d. Let\u2019s go with a simple example for details:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Consider a Class called a Car that may contain different properties(brand, model, \u2026.) and methods( start(), stop(), \u2026).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s create an instance for storing Car Object values using the Car Class as a \u201cblueprint\u201d like $carone = new Car(); You can create many \u201cinstances\u201d using that \u201cblueprint\u201d.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The \u201cnew\u201d keyword tells PHP you want a new \u201cinstance\u201d of the Car class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can set the values for the different properties and can access the methods like $carone-&gt;brand = \u2018Tesla\u2019; $carone-&gt;start();<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So after storing value in an instance, $carone is treated as Object.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Class is a &#8220;blueprint&#8221; that can use to &#8220;instantiate&#8221; different &#8220;objects&#8221;. Let&#8217;s go with a simple example for details:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","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":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"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":""},"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":""}}},"tags":[],"topics":[46],"class_list":["post-231","quick-tips","type-quick-tips","status-publish","hentry","topics-php-oop"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"WPArtisan","author_link":"https:\/\/demo.wpartisan.net\/developmentsite\/author\/developmentsiteauth\/"},"uagb_comment_info":0,"uagb_excerpt":"Class is a \"blueprint\" that can use to \"instantiate\" different \"objects\". Let's go with a simple example for details:","_links":{"self":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/quick-tips\/231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/quick-tips"}],"about":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/types\/quick-tips"}],"author":[{"embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/comments?post=231"}],"wp:attachment":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/media?parent=231"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/tags?post=231"},{"taxonomy":"topics","embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/topics?post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}