{"id":16206,"date":"2019-09-21T08:52:25","date_gmt":"2019-09-21T12:52:25","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/oop-concepts-in-php-5-in-brief\/"},"modified":"2019-09-21T08:52:25","modified_gmt":"2019-09-21T12:52:25","slug":"oop-concepts-in-php-5-in-brief","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=16206","title":{"rendered":"OOP concepts in PHP 5 in brief"},"content":{"rendered":"<h3>OOP concepts in PHP 5 in brief<\/h3>\n<p> <img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdn-images-1.medium.com\/max\/800\/1%2AUQKkJhqTgaCVWVQW2BbNXQ.jpeg?w=750&#038;ssl=1\" alt=\"1*UQKkJhqTgaCVWVQW2BbNXQ.jpeg\" \/><\/p>\n<p>OOP concepts in PHP 5 in brief<\/p>\n<p><strong>OOP concepts in PHP 5 in short<\/strong><\/p>\n<p>Why this short\u200a\u2014\u200anote? if you are familiar with OOD and any OOP language such as Java\/C++, this short note will give you enough information to start with PHP 5 OOP <strong>Class<\/strong><\/p>\n<ul>\n<li>Class definition starts with the keyword class, followed by a class name (non reserved word), followed by a pair of curly braces. The curly braces contain the definition of the classes members and methods<\/li>\n<li>You can create objects based on the classes. $obj = new className()<\/li>\n<li>You use $obj-&gt;methodName() to access a class method (public). You can use className::classMember to access class members (static): to use :: operator the method does not need to be declared static<\/li>\n<li>Inside a class all class methods have access to $this variable to refer to the calling object (if called from\/using an object)<\/li>\n<li>member declaration: public $var = \u2018a default value<\/li>\n<li>Default value always is: constant expression<\/li>\n<li><a href=\"http:\/\/ca3.php.net\/manual\/en\/ref.classobj.php\">Class\/Object Functions<\/a><\/li>\n<li>A class can use extends keyword to inherit methods and members of another class<\/li>\n<li>Multiple inheritance is not allowed<\/li>\n<li>To avoid using a long list of includes in the beginning of php files, you can use __autoload() function to do the job for you<\/li>\n<li>When you try to use an undefined class\/interface an __autoload function is automatically called<\/li>\n<li>function __autoload($class_name) {<br \/>\nrequire_once $class_name . \u2018.php\u2019;<br \/>\n}<\/li>\n<li>Constructor syntax: void __construct ([ mixed $args [, $\u2026 ]] )<\/li>\n<li>Parents\u2019 constructors are not automatically called from children\u2019s constructor. use explicit parent::__construct() instead<\/li>\n<li>Destructor syntax: void __destruct ( void )<\/li>\n<li>Destructor is called: 1. all references to the object are removed 2. the object is explicitly destroyed 3. in shutdown sequence<\/li>\n<li>Parents\u2019 destructors are not automatically called from children\u2019s destructors. use explicit parent::__destruct() instead<\/li>\n<li>Access modifiers for class members: public, protected or private: Public\u200a\u2014\u200aaccessible from anywhere. Protected\u200a\u2014\u200aaccessible from inherited and parent classes, within the class. Private\u200a\u2014\u200aaccessible within the class<\/li>\n<li>No access modifier = public<\/li>\n<li>::\u200a\u2014\u200ascope resolution operator\u200a\u2014\u200aallows access to static, constant, and overridden members or methods of a class<\/li>\n<li>Abstract classes: Introduced in PHP 5. You are not allowed to reate an instance of an abstract class.<\/li>\n<li>Even if a class contains one abstract method, the class must bedeclared abstract<\/li>\n<li>Abstract classes are just about signatures, they cannot define the implementation<\/li>\n<li>A class inheriting from an abstract class, must have to implement all abstract methods. The abstract methods must be defined with the same\/(less restricted) visibility<\/li>\n<li>Interface: Just the method signatures. No method implementation inside interfaces<\/li>\n<li>All interface methods must be public<\/li>\n<li>Classes implementing interfaces must implement all methods. Classes use implements keyword to implement an interface<\/li>\n<li>A class can not implement two interfaces having same class names<\/li>\n<li>Interfaces can be extended using extends keyword<\/li>\n<li>Interfaces can also have constants<\/li>\n<li>Overloading: Overloading in PHP = dynamically \u201ccreate\u201d members and methods<\/li>\n<li>overloading methods: invoked when interacting with non-declared\/invisible members or methods<\/li>\n<li>All overloading methods must be defined as public<\/li>\n<li>In PHP, overloading is done through magic methods<\/li>\n<li>The arguments of the magic methods can not be \u2018passed by reference\u2019<\/li>\n<li>Member overloading methods: void __set ( string $name , mixed $value ), mixed __get ( string $name ), bool __isset ( string $name ), void __unset ( string $name )<\/li>\n<li>Method overloading: mixed __call ( string $name , array $arguments ), mixed __callStatic ( string $name , array $arguments )<\/li>\n<li>Object Iteration: Inside the class<\/li>\n<li>foreach($this as $key =&gt; $value) {<br \/>\nprint \u201c$key =&gt; $valuen\u201d;<br \/>\n}<\/li>\n<\/ul>\n<ul>\n<li>Object Iteration: Outside class:<\/li>\n<li>$class = new MyClass();<br \/>\nforeach ($class as $key =&gt; $value) {<br \/>\nprint \u201c$key =&gt; $valuen\u201d;<br \/>\n}<\/li>\n<li>Patterns: Factory Pattern: allows the instantiation of objects at runtime<\/li>\n<li>Patterns: Singleton: Helps in situations where only a single instance of a class is required that will be used by many other objects<\/li>\n<li>Magic methods: have special meaning. __construct, __destruct (see Constructors and Destructors), __call, __callStatic, __get, __set, __isset, __unset, __sleep, __wakeup, __toString, __set_state and __clone<\/li>\n<li>serialize()\u200a\u2014\u200aapplies to __sleep(). unserialize() applies to __wakeup()<\/li>\n<li>final keyword: final members can not be overriden, final classes can not be extended<\/li>\n<li>$copy_of_object = clone $object; : will create a clone of $object. Unless a __clone method defined, a shadow is created. __clone() method can define how the cloning will be done<\/li>\n<li>Objects Comparison: == : two object instances are equal if they have the same attributes and values, and are instances of the same class.<\/li>\n<li>Objects Comparison: === : Object variables are identical if and only if they refer to the same instance of the same class<\/li>\n<li>Reflection APIs: to reverse-engineer classes, interfaces, functions and methods, extensions<\/li>\n<li>Reflection APIs: Offer ways to retrieve doc comments for functions, classes and methods<\/li>\n<li>Type Hinting: Functions can enforce parameters to be objects:<\/li>\n<li>Late Static Bindings: to refer the called class in a context of static inheritance.<\/li>\n<li><\/li>\n<\/ul>\n<p>Sayed Ahmed<\/p>\n<p>Linkedin: <a href=\"https:\/\/ca.linkedin.com\/in\/sayedjustetc\">https:\/\/ca.linkedin.com\/in\/sayedjustetc<\/a><\/p>\n<p>Blog: <a href=\"http:\/\/bangla.salearningschool.com\/\">http:\/\/bangla.saLearningSchool.com<\/a> <a href=\"http:\/\/sitestree.com\">http:\/\/SitesTree.com<\/a>,<br \/>\nOnline and Offline Training: <a href=\"http:\/\/training.SitesTree.com\">http:\/\/training.SitesTree.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>OOP concepts in PHP 5 in brief OOP concepts in PHP 5 in brief OOP concepts in PHP 5 in short Why this short\u200a\u2014\u200anote? if you are familiar with OOD and any OOP language such as Java\/C++, this short note will give you enough information to start with PHP 5 OOP Class Class definition starts &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=16206\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[182],"tags":[],"class_list":["post-16206","post","type-post","status-publish","format-standard","hentry","category---blog","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":70025,"url":"http:\/\/bangla.sitestree.com\/?p=70025","url_meta":{"origin":16206,"position":0},"title":"OOP concepts in PHP 5 in brief #16","author":"Author-Check- Article-or-Video","date":"August 23, 2021","format":false,"excerpt":"OOP concepts in PHP 5 in short Why this short - note? if you are familiar with OOD and any OOP language such as Java\/C++, this short note will give you enough information to start with PHP 5 OOP Class Class definition starts with the keyword class, followed by a\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":75870,"url":"http:\/\/bangla.sitestree.com\/?p=75870","url_meta":{"origin":16206,"position":1},"title":"PHP Topics to Learn","author":"Sayed","date":"August 1, 2023","format":false,"excerpt":"Identifiers https:\/\/docstore.mik.ua\/orelly\/webprog\/php\/ch02_01.htm#:~:text=An%20identifier%20is%20simply%20a,ASCII%200x7F%20and%20ASCII%200xFF. PHP Data Types https:\/\/www.odinschool.com\/learning-hub\/php\/datatypes Type Hinting https:\/\/www.honeybadger.io\/blog\/php-type-hinting\/#:~:text=Type%2Dhinting%20means%20explicitly%20stating,to%20write%20more%20robust%20code. PDO and MySQL https:\/\/www.w3schools.com\/php\/php_mysql_connect.asp PHP OOP https:\/\/www.w3schools.com\/php\/php_oop_what_is.asp abstract classes https:\/\/www.w3schools.com\/php\/php_oop_classes_abstract.asp Abstract vs Interface https:\/\/www.w3schools.com\/php\/php_oop_interfaces.asp#:~:text=PHP%20%2D%20Interfaces%20vs.%20Abstract%20Classes&text=Interfaces%20cannot%20have%20properties%2C%20while,abstract%20keyword%20is%20not%20necessary , methods, interfaces, and inheritance Pillars of OOP The Four pillars of OOPs, abstraction, encapsulation, inheritance, and polymorphism, are integral to understanding and using OOP https:\/\/datatrained.com\/post\/four-pillars-of-oops\/#:~:text=The%20Four%20pillars%20of%20OOPs%2C%20abstraction%2C%20encapsulation%2C%20inheritance%2C,to%20understanding%20and%20using%20OOP. Four\u2026","rel":"","context":"In &quot;PHP&quot;","block_context":{"text":"PHP","link":"http:\/\/bangla.sitestree.com\/?cat=1427"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":68580,"url":"http:\/\/bangla.sitestree.com\/?p=68580","url_meta":{"origin":16206,"position":2},"title":"C++ Concepts and Syntax #77","author":"Author-Check- Article-or-Video","date":"August 5, 2021","format":false,"excerpt":"Not really for the beginners. If you had experience working with C++ in the past, then taking a look at this short-note will help to recover your knowledge in C++. Multiple inheritance means that one subclass can have more than one superclass. This enables the subclass to inherit properties of\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65844,"url":"http:\/\/bangla.sitestree.com\/?p=65844","url_meta":{"origin":16206,"position":3},"title":"Java : SCJP: Important Resources #Java Short Notes #SCJP","author":"Sayed","date":"July 16, 2021","format":false,"excerpt":"How to use generics to avoid runtime errors. More Generics Class casting in Java: How to avoid runtime exception - ClassCastException: overloading, overriding, variable and method hiding Java HotSpot virtual machine What Java Technology can do? Offers from Java Technology Java:Common Problems (and Their Solutions) Benefits of OOP: Modularity, Information-hiding,\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":78414,"url":"http:\/\/bangla.sitestree.com\/?p=78414","url_meta":{"origin":16206,"position":4},"title":"Differences among Functional Diagrams, Activity Diagrams, Sequence Diagrams, and Class Diagrams? Why are these important in OOD and OOP.","author":"Sayed","date":"August 27, 2025","format":false,"excerpt":"Got it \ud83d\udc4d I\u2019ll structure everything into a clear comparison table that\u2019s easy to read and copyright-free for posting on your FB\/blog. \ud83d\udcd8 OOD & OOP Diagrams \u2013 Quick Comparison Diagram TypePurpose \/ FocusStatic or DynamicExample UseFunctional DiagramShows system functions and how data flows between them.Static (overview level)Mapping out major\u2026","rel":"","context":"In &quot;Enterprise Architect&quot;","block_context":{"text":"Enterprise Architect","link":"http:\/\/bangla.sitestree.com\/?cat=98"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/08\/image-22.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/08\/image-22.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/08\/image-22.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/08\/image-22.png?resize=700%2C400 2x"},"classes":[]},{"id":78161,"url":"http:\/\/bangla.sitestree.com\/?p=78161","url_meta":{"origin":16206,"position":5},"title":"Misc. Short Notes on Visual Studio and C#","author":"Sayed","date":"May 11, 2025","format":false,"excerpt":"Download Visual Studio Community Edition: https:\/\/visualstudio.microsoft.com\/vs\/community Compare Different Versions of Visual Studio: https:\/\/visualstudio.microsoft.com\/vs\/compare IPO Diagram for Your Code (Application) IPO Diagram visually shows\/describes key inputs, Processes\/Operations, and resulting outputs from those operations. Ref: https:\/\/www.youtube.com\/watch?v=a10a11oxjrA&pp=0gcJCdgAo7VqN5tD For UML class diagram Concepts, please check: https:\/\/www.visual-paradigm.com\/guide\/uml-unified-modeling-language\/uml-class-diagram-tutorial An example from the URL above: In Object\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/05\/image-7.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/05\/image-7.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/05\/image-7.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/05\/image-7.png?resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/16206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16206"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/16206\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16206"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}