In this presentation, we will be talking about a migration of PHP development model from Procedural to OOP (Object Oriented Programming). This slide is a part of PHP ID (PHP Indonesia) Online Learning #6
The document provides an introduction to object oriented programming concepts in PHP. It discusses the differences between procedural and object oriented code, basic OO concepts like classes, objects, properties, methods, constructors and destructors. It also covers inheritance, visibility, static members, and differences between PHP4 and PHP5 OOP. It uses requests as a case study and provides homework and suggested reading.
This document provides an overview of object-oriented programming (OOP) concepts in PHP. It discusses key OOP features like classes, objects, inheritance, encapsulation, abstraction, and interfaces. It explains why OOP is useful for modularity, abstraction, information hiding, structured design, hierarchy, and continuity. Main language features in PHP like classes, inheritance, visibility, abstraction, interfaces, and polymorphism are also covered. Real-world examples of classes, objects, inheritance and interfaces in PHP code are provided.
This document provides an overview of PHP basics covered in Session One of a CFPHP ZCE Training. It introduces PHP files and data types like integers, floats, strings, booleans, and arrays. It also covers variables, constants, operators, and basic control structures like conditionals and loops. The document concludes with an overview of error handling in PHP.
The document discusses object-oriented programming (OOP) principles and design patterns in PHP, explaining key OOP concepts like encapsulation, inheritance, and polymorphism. Several common design patterns are described, including singleton, factory, observer, and proxy patterns, and how they can help solve recurring problems by promoting code reuse. The document provides examples of applying these patterns in PHP code to handle issues like object aggregation, iteration, and dynamic method dispatching.
If you are new to programing in general OR if you started programing in php before Object-Oriented Programming was even available, this presentation is designed to help you get up to speed on Object-Oriented terminology and give you practical skills as well as resources to continue learning.
When developers are introduced to object-oriented programming, one of the first things they are taught is that nouns turn into objects, verbs into methods, and Dog is a subclass of Animal. OOP is more than just turning things into classes and objects and showing that both Boats and Cars have motors, and that Dogs and Cats both speak(). Let's look at OOP in real-world settings and go beyond cars and dogs to see how to use object-oriented programming properly in PHP. Traits, composition, inheritance – none of it is off limits!
Increase your PHP skills and improve your architecture as you learn why, when, and how to use advanced PHP features. Abstracts, interfaces, traits, namespaces, and dependency injection will each be discussed with code examples to help make using them simple. All these features will then be brought together to demonstrate clean coding. This will be a perfect presentation to help you sharpen your skill-set to include these tools to make your code even more clean, structured, and awesome!
This PPT gives information about:
Advanced Theories
Inheriting Classes
Inheriting Constructors and Destructors
Overriding Methods
Access Control
Using the Scope Resolution Operator
Creating Static Members
Abstract Classes and Methods
The document provides an introduction to object oriented programming concepts in PHP. It discusses the differences between procedural and object oriented code, basic OO concepts like classes, objects, properties, methods, constructors and destructors. It also covers inheritance, visibility, static members, and differences between PHP4 and PHP5 OOP. It uses requests as a case study and provides homework and suggested reading.
This document provides an overview of object-oriented programming (OOP) concepts in PHP. It discusses key OOP features like classes, objects, inheritance, encapsulation, abstraction, and interfaces. It explains why OOP is useful for modularity, abstraction, information hiding, structured design, hierarchy, and continuity. Main language features in PHP like classes, inheritance, visibility, abstraction, interfaces, and polymorphism are also covered. Real-world examples of classes, objects, inheritance and interfaces in PHP code are provided.
This document provides an overview of PHP basics covered in Session One of a CFPHP ZCE Training. It introduces PHP files and data types like integers, floats, strings, booleans, and arrays. It also covers variables, constants, operators, and basic control structures like conditionals and loops. The document concludes with an overview of error handling in PHP.
The document discusses object-oriented programming (OOP) principles and design patterns in PHP, explaining key OOP concepts like encapsulation, inheritance, and polymorphism. Several common design patterns are described, including singleton, factory, observer, and proxy patterns, and how they can help solve recurring problems by promoting code reuse. The document provides examples of applying these patterns in PHP code to handle issues like object aggregation, iteration, and dynamic method dispatching.
If you are new to programing in general OR if you started programing in php before Object-Oriented Programming was even available, this presentation is designed to help you get up to speed on Object-Oriented terminology and give you practical skills as well as resources to continue learning.
When developers are introduced to object-oriented programming, one of the first things they are taught is that nouns turn into objects, verbs into methods, and Dog is a subclass of Animal. OOP is more than just turning things into classes and objects and showing that both Boats and Cars have motors, and that Dogs and Cats both speak(). Let's look at OOP in real-world settings and go beyond cars and dogs to see how to use object-oriented programming properly in PHP. Traits, composition, inheritance – none of it is off limits!
Increase your PHP skills and improve your architecture as you learn why, when, and how to use advanced PHP features. Abstracts, interfaces, traits, namespaces, and dependency injection will each be discussed with code examples to help make using them simple. All these features will then be brought together to demonstrate clean coding. This will be a perfect presentation to help you sharpen your skill-set to include these tools to make your code even more clean, structured, and awesome!
This PPT gives information about:
Advanced Theories
Inheriting Classes
Inheriting Constructors and Destructors
Overriding Methods
Access Control
Using the Scope Resolution Operator
Creating Static Members
Abstract Classes and Methods
OOP in PHP allows for the creation of classes and objects. A class defines properties and methods, while an object is an instance of a class. Key OOP concepts include inheritance, where a child class extends a parent class; encapsulation, which hides internal data; and polymorphism through inheritance and method overriding. Exceptions can be thrown and caught to handle errors or unexpected behavior.
Software development is hard! SOLID coding principles can help you develop better code. Come learn what the SOLID principles are and practical examples on how to use each strategy when developing in PHP. Leave with the tools needed to architect code that follows established design patterns that lead to better code.
The document provides an introduction to object-oriented programming (OOP) concepts in C++ including objects, classes, abstraction, encapsulation, inheritance, polymorphism, constructors, destructors, and exception handling. It defines each concept and provides examples of how it is implemented in C++ code. For instance, it explains that a class is a user-defined data type that holds its own data members and member functions, and provides an example class declaration. It also discusses polymorphism and provides examples demonstrating method overloading and overriding.
The document discusses object-oriented programming (OOP) in PHP. It covers what OOP is, why it should be used in PHP, how to implement OOP in PHP code, and where OOP is commonly used. Key benefits of OOP highlighted include flexibility, reduced code size, improved security, and easier organization of code. The principles of MVC (model-view-controller) design pattern are also explained as they relate to OOP.
Object Oriented Programming (OOP) allows developers to organize complex programs using classes and objects. OOP uses concepts like encapsulation, inheritance and polymorphism to keep data and functionality together in objects. The basic building blocks in OOP are classes, which define the properties and methods of an object, and objects, which are instances of classes. Classes can inherit properties and methods from parent classes, and objects can be identified and compared using operators like instanceof. Magic methods allow objects to override default behavior for operations like property access, method calling and object destruction.
Coming to Terms with OOP In Drupal - php[world] 2016Chris Tankersley
The document discusses object-oriented programming (OOP) concepts in PHP and Drupal, including classes, objects, inheritance, composition, interfaces, and design principles like the single responsibility principle. It provides examples of how procedural code can be rewritten using OOP patterns to make the code more modular, reusable, and testable. Key benefits of OOP like code reuse and extensibility are highlighted.
Object Oriented Programming with PHP 5 - More OOPWildan Maulana
The document discusses object-oriented programming concepts in PHP 5 such as class information functions, checking if a class exists, finding loaded classes, checking for methods and properties, class types, and class names. It also covers exception handling, iterators, the ArrayObject class, serialization, cloning, autoloading classes, and method chaining in PHP 5 OOP.
OOP Is More Then Cars and Dogs - Midwest PHP 2017Chris Tankersley
When developers are introduced to Object Oriented Programming, one of the first things that happens is that they are taught that nouns turn into objects, verbs into methods, and Dog is a subclass of Animal. OOP is more than just turning things into classes and objects and showing that both Boats and Cars have motors, and that Dogs and Cats both speak(). Let's look at OOP in real world settings and go beyond cars and dogs, and see how to use Object Oriented Programming properly in PHP. Traits, Composition, Inheritance, none of it is off limits!
Vision academy classes bcs_bca_bba_sybba_phpsachin892777
The document provides an overview of the PHP programming language. It discusses what PHP is, its features, basic syntax, variables, data types, operators, conditional statements, loops, forms handling, functions, and variable scopes. Some key points covered include:
- PHP is a server-side scripting language used for web development that allows embedding code into HTML pages.
- It is cross-platform, open source, and compatible with many servers.
- Basic PHP syntax involves wrapping code within <?php ?> tags.
- Variables start with $ and are case-sensitive. Common data types include integers, floats, booleans, strings, arrays, and objects.
- Operators include arithmetic, comparison, logical
This document summarizes an upcoming webinar on Python. The webinar will cover object-oriented programming in Python, Numpy, and Pandas. It provides background on procedural programming versus object-oriented programming, describing key concepts of OOP like classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It then goes into detail explaining each of these OOP concepts through examples and definitions.
The document provides information about an intermediate PHP OOP conference session covering magic methods, polymorphism, collections, iterators, loose coupling, and high cohesion. The session details include explanations of magic methods like __construct, __destruct, __call, and __get, as well as polymorphism, implementing interfaces like Countable and ArrayAccess, and using iterators. The talk aims to improve developers' OOP skills in PHP.
The genetic characters transmitted from parent to offspring, taken collectively.
Something, as a quality, characteristic, or other immaterial possession, received from progenitors or predecessors as if by succession.
↓↓↓↓ Read More:
@ Kindly Follow my Instagram Page to discuss about your mental health problems-
-----> https://instagram.com/mentality_streak?utm_medium=copy_link
@ Appreciate my work:
-----> behance.net/burhanahmed1
Thank-you !
The document discusses James Edward Gray II's contributions to Ruby programming and his trip to RubyKaigi2009 in Japan. It then covers several topics related to Ruby modules, including using modules to group constants, modules acting as both namespaces and mixins, extending objects with modules instead of inheritance, and using modules to label and modify objects. The key ideas are that mastering Ruby's method lookup is worthwhile, modules are great for limiting the scope of code, and modules can customize individual objects.
Abstraction, Encapsulation, Polymorphism, and Interfaces: whether you’ve been programming in PHP for years or are just starting your journey, these terms can be overwhelming even on a good day. Variables, conditionals, those all make sense. But this whole Object-Oriented thing is WAY more complicated. Not only that, people that already understand it act like it’s so easy and they talk right over the simple questions and never explain the basic concepts in a way that actually makes sense. In this session we’ll take you through real life examples of Object-Oriented terminology in a way that will make sense of all the mumbo jumbo and allow you to utilizing OOP immediately.
This document provides an overview of object-oriented programming concepts like classes, objects, encapsulation, inheritance, polymorphism, and data hiding. It explains key OOP concepts like classes define custom data types with attributes and methods, objects are instances of classes, encapsulation groups related data and code, inheritance creates specialized classes from general classes, polymorphism allows one interface for multiple forms. It also discusses concepts like abstract classes, interfaces, constructors, destructors, operator overloading and access modifiers for data hiding. Overall, the document serves as an introduction to fundamental OOP principles in C++.
1. A delegate is an object type that encapsulates a method call and handles events. It allows a method to be called if the method signature and return type match the delegate.
2. There are two types of delegates: single-cast delegates allow one delegate object to call one method, while multicast delegates allow one delegate object to call multiple methods in sequence.
3. An anonymous method is a collection of statements that is directly passed to a delegate without a specific name. It demonstrates how delegates work like in real life by allowing one entity (like a teacher) to delegate a task (making tea) through another (a peon) to the handler (tea maker).
- The document discusses object-oriented programming concepts in PHP including classes, objects, encapsulation, inheritance, and polymorphism.
- It provides examples of defining classes with properties and methods, and using access specifiers like public, private, and protected.
- Constructors and destructors are explained, as well as how to instantiate objects and use objects in arrays or pass them as references to functions.
Inheritance allows a subclass to inherit properties and methods from a superclass. There are several types of inheritance in Java including single, multilevel, hierarchical, and hybrid inheritance. Single inheritance involves a subclass extending one superclass. Multilevel inheritance allows a subclass to inherit from another subclass. Hierarchical inheritance has one superclass with multiple subclasses. Hybrid inheritance combines single and multiple inheritance by implementing interfaces.
This document summarizes an Object Oriented Programming (OOP) lesson on PHP classes. It introduces how to create classes and objects, define properties and methods, use access modifiers like public and private, extend classes through inheritance, and implement interfaces. Key concepts covered include creating objects, accessing properties and methods, using class constants, constructors and destructors, overriding and extending classes, and polymorphism.
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
This document provides an overview of object-oriented programming (OOP) concepts in PHP. It discusses the basics of OOP including classes, objects, inheritance, and polymorphism. It also demonstrates how to define classes, create objects, access properties and methods, use constructors and destructors, implement inheritance and method overriding in PHP code. Advanced topics like chained inheritance, introspection functions, and OOP best practices are also mentioned.
The document discusses object-oriented programming concepts in PHP including classes, objects, inheritance, encapsulation, and polymorphism. It provides examples of defining classes, creating objects, accessing properties and methods, constructors, destructors, inheritance, overriding methods, scopes, interfaces, constants, abstract classes, and calling parent functions. The document is an introduction to object-oriented programming in PHP and covers the basic syntax and constructs.
OOP in PHP allows for the creation of classes and objects. A class defines properties and methods, while an object is an instance of a class. Key OOP concepts include inheritance, where a child class extends a parent class; encapsulation, which hides internal data; and polymorphism through inheritance and method overriding. Exceptions can be thrown and caught to handle errors or unexpected behavior.
Software development is hard! SOLID coding principles can help you develop better code. Come learn what the SOLID principles are and practical examples on how to use each strategy when developing in PHP. Leave with the tools needed to architect code that follows established design patterns that lead to better code.
The document provides an introduction to object-oriented programming (OOP) concepts in C++ including objects, classes, abstraction, encapsulation, inheritance, polymorphism, constructors, destructors, and exception handling. It defines each concept and provides examples of how it is implemented in C++ code. For instance, it explains that a class is a user-defined data type that holds its own data members and member functions, and provides an example class declaration. It also discusses polymorphism and provides examples demonstrating method overloading and overriding.
The document discusses object-oriented programming (OOP) in PHP. It covers what OOP is, why it should be used in PHP, how to implement OOP in PHP code, and where OOP is commonly used. Key benefits of OOP highlighted include flexibility, reduced code size, improved security, and easier organization of code. The principles of MVC (model-view-controller) design pattern are also explained as they relate to OOP.
Object Oriented Programming (OOP) allows developers to organize complex programs using classes and objects. OOP uses concepts like encapsulation, inheritance and polymorphism to keep data and functionality together in objects. The basic building blocks in OOP are classes, which define the properties and methods of an object, and objects, which are instances of classes. Classes can inherit properties and methods from parent classes, and objects can be identified and compared using operators like instanceof. Magic methods allow objects to override default behavior for operations like property access, method calling and object destruction.
Coming to Terms with OOP In Drupal - php[world] 2016Chris Tankersley
The document discusses object-oriented programming (OOP) concepts in PHP and Drupal, including classes, objects, inheritance, composition, interfaces, and design principles like the single responsibility principle. It provides examples of how procedural code can be rewritten using OOP patterns to make the code more modular, reusable, and testable. Key benefits of OOP like code reuse and extensibility are highlighted.
Object Oriented Programming with PHP 5 - More OOPWildan Maulana
The document discusses object-oriented programming concepts in PHP 5 such as class information functions, checking if a class exists, finding loaded classes, checking for methods and properties, class types, and class names. It also covers exception handling, iterators, the ArrayObject class, serialization, cloning, autoloading classes, and method chaining in PHP 5 OOP.
OOP Is More Then Cars and Dogs - Midwest PHP 2017Chris Tankersley
When developers are introduced to Object Oriented Programming, one of the first things that happens is that they are taught that nouns turn into objects, verbs into methods, and Dog is a subclass of Animal. OOP is more than just turning things into classes and objects and showing that both Boats and Cars have motors, and that Dogs and Cats both speak(). Let's look at OOP in real world settings and go beyond cars and dogs, and see how to use Object Oriented Programming properly in PHP. Traits, Composition, Inheritance, none of it is off limits!
Vision academy classes bcs_bca_bba_sybba_phpsachin892777
The document provides an overview of the PHP programming language. It discusses what PHP is, its features, basic syntax, variables, data types, operators, conditional statements, loops, forms handling, functions, and variable scopes. Some key points covered include:
- PHP is a server-side scripting language used for web development that allows embedding code into HTML pages.
- It is cross-platform, open source, and compatible with many servers.
- Basic PHP syntax involves wrapping code within <?php ?> tags.
- Variables start with $ and are case-sensitive. Common data types include integers, floats, booleans, strings, arrays, and objects.
- Operators include arithmetic, comparison, logical
This document summarizes an upcoming webinar on Python. The webinar will cover object-oriented programming in Python, Numpy, and Pandas. It provides background on procedural programming versus object-oriented programming, describing key concepts of OOP like classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It then goes into detail explaining each of these OOP concepts through examples and definitions.
The document provides information about an intermediate PHP OOP conference session covering magic methods, polymorphism, collections, iterators, loose coupling, and high cohesion. The session details include explanations of magic methods like __construct, __destruct, __call, and __get, as well as polymorphism, implementing interfaces like Countable and ArrayAccess, and using iterators. The talk aims to improve developers' OOP skills in PHP.
The genetic characters transmitted from parent to offspring, taken collectively.
Something, as a quality, characteristic, or other immaterial possession, received from progenitors or predecessors as if by succession.
↓↓↓↓ Read More:
@ Kindly Follow my Instagram Page to discuss about your mental health problems-
-----> https://instagram.com/mentality_streak?utm_medium=copy_link
@ Appreciate my work:
-----> behance.net/burhanahmed1
Thank-you !
The document discusses James Edward Gray II's contributions to Ruby programming and his trip to RubyKaigi2009 in Japan. It then covers several topics related to Ruby modules, including using modules to group constants, modules acting as both namespaces and mixins, extending objects with modules instead of inheritance, and using modules to label and modify objects. The key ideas are that mastering Ruby's method lookup is worthwhile, modules are great for limiting the scope of code, and modules can customize individual objects.
Abstraction, Encapsulation, Polymorphism, and Interfaces: whether you’ve been programming in PHP for years or are just starting your journey, these terms can be overwhelming even on a good day. Variables, conditionals, those all make sense. But this whole Object-Oriented thing is WAY more complicated. Not only that, people that already understand it act like it’s so easy and they talk right over the simple questions and never explain the basic concepts in a way that actually makes sense. In this session we’ll take you through real life examples of Object-Oriented terminology in a way that will make sense of all the mumbo jumbo and allow you to utilizing OOP immediately.
This document provides an overview of object-oriented programming concepts like classes, objects, encapsulation, inheritance, polymorphism, and data hiding. It explains key OOP concepts like classes define custom data types with attributes and methods, objects are instances of classes, encapsulation groups related data and code, inheritance creates specialized classes from general classes, polymorphism allows one interface for multiple forms. It also discusses concepts like abstract classes, interfaces, constructors, destructors, operator overloading and access modifiers for data hiding. Overall, the document serves as an introduction to fundamental OOP principles in C++.
1. A delegate is an object type that encapsulates a method call and handles events. It allows a method to be called if the method signature and return type match the delegate.
2. There are two types of delegates: single-cast delegates allow one delegate object to call one method, while multicast delegates allow one delegate object to call multiple methods in sequence.
3. An anonymous method is a collection of statements that is directly passed to a delegate without a specific name. It demonstrates how delegates work like in real life by allowing one entity (like a teacher) to delegate a task (making tea) through another (a peon) to the handler (tea maker).
- The document discusses object-oriented programming concepts in PHP including classes, objects, encapsulation, inheritance, and polymorphism.
- It provides examples of defining classes with properties and methods, and using access specifiers like public, private, and protected.
- Constructors and destructors are explained, as well as how to instantiate objects and use objects in arrays or pass them as references to functions.
Inheritance allows a subclass to inherit properties and methods from a superclass. There are several types of inheritance in Java including single, multilevel, hierarchical, and hybrid inheritance. Single inheritance involves a subclass extending one superclass. Multilevel inheritance allows a subclass to inherit from another subclass. Hierarchical inheritance has one superclass with multiple subclasses. Hybrid inheritance combines single and multiple inheritance by implementing interfaces.
This document summarizes an Object Oriented Programming (OOP) lesson on PHP classes. It introduces how to create classes and objects, define properties and methods, use access modifiers like public and private, extend classes through inheritance, and implement interfaces. Key concepts covered include creating objects, accessing properties and methods, using class constants, constructors and destructors, overriding and extending classes, and polymorphism.
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
This document provides an overview of object-oriented programming (OOP) concepts in PHP. It discusses the basics of OOP including classes, objects, inheritance, and polymorphism. It also demonstrates how to define classes, create objects, access properties and methods, use constructors and destructors, implement inheritance and method overriding in PHP code. Advanced topics like chained inheritance, introspection functions, and OOP best practices are also mentioned.
The document discusses object-oriented programming concepts in PHP including classes, objects, inheritance, encapsulation, and polymorphism. It provides examples of defining classes, creating objects, accessing properties and methods, constructors, destructors, inheritance, overriding methods, scopes, interfaces, constants, abstract classes, and calling parent functions. The document is an introduction to object-oriented programming in PHP and covers the basic syntax and constructs.
The document discusses object-oriented programming concepts in PHP including classes, objects, inheritance, encapsulation, and polymorphism. It provides examples of defining classes, creating objects, accessing properties and methods, constructors, destructors, inheritance, overriding methods, scopes, interfaces, constants, abstract classes, and calling parent functions. Key concepts are explained like public, private, and protected access modifiers, abstract classes and methods, and using parent, self and static keywords.
This document discusses object-oriented programming (OOP) concepts in PHP including access specifiers, properties, methods, the $this keyword, instanceof, and static properties and methods. Code examples are provided to demonstrate how to create a PHP class with properties and methods, set property values using $this, check if an object belongs to a class using instanceof, and define static properties and methods. The document concludes with problems to solve involving writing PHP classes to display messages, calculate factorials, perform basic math operations, calculate averages, and calculate triangle areas and perimeters.
This document provides an introduction to object oriented PHP by explaining key concepts like encapsulation, inheritance, polymorphism, and abstraction. It defines classes, objects, properties, methods, and constructs. Examples are provided to demonstrate how to define classes, instantiate objects, set properties, create and extend classes, implement interfaces and abstract classes, and override methods.
Object oriented programming uses concepts like encapsulation, inheritance and polymorphism to create robust and secure code. The key concepts are:
1. Encapsulation and data abstraction which group data and functions that work on that data.
2. Inheritance allows code reusability through parent-child class relationships in multilevel and multiple inheritance.
3. Polymorphism enables one interface and different actions through inheritance.
PHP is an object-oriented programming language that supports fundamental object-oriented programming features like encapsulation, inheritance, and polymorphism. Key concepts covered in the document include:
- Classes allow data and functions to be grouped together, and instances of classes are called objects.
- Access specifiers like public, private, and protected determine visibility of class members. Private members can only be accessed within the class, while public members can be accessed anywhere.
- Constructors are special methods that initialize an object when it is created. Destructors are called when objects are destroyed.
- Inheritance allows new classes to inherit attributes and behaviors from existing classes. Polymorphism allows different classes to have similarly
The document summarizes Alena Holligan's presentation on demystifying object-oriented programming. The presentation covers object-oriented programming terminology like classes, objects, and inheritance. It also discusses polymorphism through inheritance, interfaces, abstract classes, and traits. The presentation then covers magic methods, magic constants, static properties and methods, and scope. It provides examples to illustrate these concepts. The presentation aims to help explain object-oriented programming concepts and terminology.
This document discusses object-oriented programming concepts like inheritance, overriding methods, copy constructors, encapsulation, and abstraction. It provides examples of each concept. Specifically, it explains that inheritance allows child classes to access parent properties and methods, and override parent methods. Encapsulation binds properties and methods together in a class and uses access modifiers like private and public. Abstraction hides unnecessary details and shows essential attributes, using abstract classes and methods. The key difference between abstraction and encapsulation is that abstraction focuses on design while encapsulation focuses on implementation.
Part 3 of a bespoke in-company training. Complete set of slides under:
Part 1: https://www.slideshare.net/VasilyKartashov/effective-php-part-1
Part 2: https://www.slideshare.net/VasilyKartashov/effective-php-part-2
Part 3: https://www.slideshare.net/VasilyKartashov/effective-php-part-3
Part 4: https://www.slideshare.net/VasilyKartashov/effective-php-part-4
Part 5: https://www.slideshare.net/VasilyKartashov/effective-php-part-5
Part 6: https://www.slideshare.net/VasilyKartashov/effective-php-part-6
More about the author: http://notes.kartashov.com/about/
Alena Holligan presented on demystifying object-oriented programming in PHP. She discussed key OOP concepts like classes, objects, inheritance, polymorphism, interfaces, abstract classes and traits. The presentation covered terminology, creating classes and objects, encapsulation, inheritance and polymorphism through subclasses and interfaces. Later sections discussed namespaces, type declarations, magic methods, magic constants and static methods. The goal was to explain core OOP concepts in PHP through examples and challenges for attendees.
PHP 5.3 introduced many new features and improvements including:
- Performance improvements with up to 40% faster speeds on Windows and 5-15% overall.
- New error reporting levels, garbage collection, and the MySQLnd native driver.
- Backwards compatibility changes like deprecated EREG functions and magic methods requirements.
- Namespaces, late static bindings, closures/lambdas, the __callStatic magic method, and get_called_class().
- Additions to the SPL like new iterators, the date/time object, and new constants like __DIR__ and __NAMESPACE__.
When developers are introduced to Object Oriented Programming, one of the first things that happens is that they are taught that nouns turn into objects, verbs into methods, and Dog is a subclass of Animal. OOP is more than just turning things into classes and objects and showing that both Boats and Cars have motors, and that Dogs and Cats both speak(). Let's look at OOP in real world settings and go beyond cars and dogs, and see how to use Object Oriented Programming properly in PHP. Traits, Composition, Inheritance, none of it is off limits! (No animals were harmed in preparation for this talk, though there was mention of showing how a dog can have wheels. And yes, the title is supposed to be Cars and Dogs.)
- Object-oriented programming (OOP) refers to the creation of reusable software objects/classes that can be efficiently developed and incorporated into multiple programs. An OOP program consists of interacting objects that solve a task.
- Classes define objects of the same type through data members (properties) and methods. Objects are instances of classes that can inherit properties and behaviors from parent classes.
- OOP principles like encapsulation, inheritance, and polymorphism help manage complexity through modularization and reuse when building large PHP programs.
Demystifying Object-Oriented Programming - Lone Star PHPAlena Holligan
Abstraction, Encapsulation, Polymorphism, and Interfaces: whether you’ve been programming in PHP for years or are just starting your journey, these terms can be overwhelming even on a good day. Variables, conditionals, those all make sense. But this whole Object-Oriented thing is WAY more complicated. Not only that, people that already understand it act like it’s so easy and they talk right over the simple questions and never explain the basic concepts in a way that actually makes sense. In this session we’ll take you through real life examples of Object-Oriented terminology in a way that will make sense of all the mumbo jumbo and allow you to utilizing OOP immediately.
Core Java Programming Language (JSE) : Chapter II - Object Oriented Programming.WebStackAcademy
Object-oriented programming (OOP) refers to a type of computer programming (software design) in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure.
In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects.
If you are new to object-oriented programming languages, you will need to know a few basics before you can get started with code. The following definitions will help you better understand object-oriented programming:
Abstraction: The process of picking out (abstracting) common features of objects and procedures.
Class: A category of objects. The class defines all the common properties of the different objects that belong to it.
Encapsulation: The process of combining elements to create a new entity. A procedure is a type of encapsulation because it combines a series of computer instructions.
Information hiding: The process of hiding details of an object or function. Information hiding is a powerful programming technique because it reduces complexity.
Inheritance: a feature that represents the "is a" relationship between different classes.
Interface: the languages and codes that the applications use to communicate with each other and with the hardware.
Messaging: Message passing is a form of communication used in parallel programming and object-oriented programming.
Object: a self-contained entity that consists of both data and procedures to manipulate the data.
Polymorphism: A programming language's ability to process objects differently depending on their data type or class.
This document discusses migrating from Drupal 6 and 7 to Drupal 8. It provides an overview of the Migrate module, which allows importing content and configuration from other Drupal versions or external systems. Key aspects covered include the source and destination plugins, processing pipelines, and the overall migration workflow of mapping, processing and importing data. Examples of how to configure and execute migrations using Drush or custom code are also presented.
Similar to PHPID online Learning #6 Migration from procedural to OOP (20)
The document provides an introduction to MPLS (Multi-Protocol Label Switching) covering its definition, advantages, architecture, labels, label switching path setup, and forwarding operations. Key points include:
- MPLS encapsulates packets with short fixed-length labels to enable faster forwarding based on the label rather than the IP address.
- MPLS decouples routing from forwarding and supports traffic engineering and virtual private networks.
- The MPLS architecture consists of label edge routers, label switch routers, label distribution protocols, and label forwarding tables.
- Labels are assigned and distributed to establish label switched paths for forwarding packets across the MPLS network.
This document discusses backup and restore strategies in Solaris OS. It begins by explaining the basic terms of backup, restore and archive. It then discusses which files should be backed up, how often backups should occur and when backups should take place to minimize impact. The document also covers how long data should be stored, where backup tapes or files should be stored, how often tapes should be retired and the evolution of backup methods from standalone to network-based solutions. Finally, it discusses different backup strategies like full, incremental and differential backups and provides examples of using various Solaris backup tools like tar, ufsdump, ufsrestore, fssnap and flash archive.
In this presentation, we are comparing the two most commonly used routing protocols in the world: BGP and OSPF. we discuss their similarities and differences
in this presentation, i will discuss about common issues that might happen when implementing load balancing. i will start the presentation with fundamental concepts that many people missed. and then discuss some implementation of it with demo.
In this webinar, we discussed an advanced topic of mikrotik firewall features: nth packet matcher. we assumed the readers already have a solid understanding of prerequisite knowledge.
we started the discussion with the basic concepts of traffic load balancing, and then move to the nth discussion.
The recording is available on youtube (GLC Networks Channel): https://youtu.be/s0JxxdKuh58
In this webinar, we started the discussion with the basic concepts of firewall in mikrotik. We then focusing on firewall mangle as it is said in title.
we discussed three most-used mangle action on mikrotik routerOS, they are: mark-packet, mark-connection, mark-routing. each mangle action has its own example case of its usage.
The recording is available on youtube (GLC Networks Channel): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
In this webinar, we started the discussion about essential concept of multiplexed communication which is applied on wired and wireless communication. we then carried on with CSMA/CD, how wireless communication works, CSMA/CA, and wireless configuration on mikrotik.
The recording is available on youtube (GLC Networks Channel): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
In this webinar, we will discuss about the basic concept of security, confidentiality, encryption, symmetric and assymetric encryption, SSL certificate, and HTTPS.
after that we discuss certificate feature on Mikrotik RouterOS, creating self-signed certificate, and import CA signed certificate to RouterOS.
The recording is available on youtube (GLC Networks Channel): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
In this webinar, we start the discussion with an introduction to BGP like AS to AS connection, comparison BGP routing and traditional routing, also BGP peering. we then talk about problem that might occur during BGP peering, its effects, and the solution. finally we cover an example of how to configure BGP filter on mikrotik.
The recording is available on youtube (GLC Networks Channel): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
In this webinar, we discuss a mikrotik feature that is called VRRP (Virtual Router Redundancy Protocol ) which could provide dedundancy on the your network. We started the webinar by introducing the VRRP protocol, then discuss an example implementation on Mikrotik Router. some mistakes on VRRP configuration were also covered here.
The recording is available on youtube (GLC Networks Channel): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
This document contains the slides for a webinar presented by Achmad Mardiansyah from GLC Networks on Mikrotik fasttrack. The webinar discusses how fasttrack can improve router performance by skipping processing posts for certain connections. Fasttrack works by applying connection tracking and NAT acceleration to specific connections marked using the firewall's fasttrack-connection action. The webinar demonstrates how to configure fasttrack rules and check fasttrack status, with cautions that fasttracked packets bypass processing like queues. Attendees are invited to register for GLC Network's Mikrotik training courses.
In this webinar, we discuss a feature from mikrotik routerOS that is called fastpath. This feature will improve routerboard performance by increasing number of packet per second and lowering CPU usage. Fastpath requires several conditions to be active, and the webinar is talking about them.
the recording is available on youtube (GLC Networks Channel): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
This topic was presented at Mikrotik user Meeting (MUM), Laos, may 8, 2017.
The primary focus on this presentation is the Quickset feature which can save lots of time to configure their RouterOS.
In this webinar, we were discussing about Network Address Translation (NAT), how NAT was born, NAT drawbacks, and how get rid of it. there are some examples of how we setup NAT in RouterOS.
the recording is available on youtube (GLC NETWORKS CHANNEL): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
In this webinar, we were discussing about layered network, protocols, protocol analyzer, and why those were designed like that. we discussed several features on mikrotik RouterOS that can be used as traffic sniffer to capture flowing packets.
the recording is available on youtube (GLC NETWORKS CHANNEL): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
In this webinar, we were discussing about Dynamic Routing with RIP (Routing Information Protocol). we discussed what is it, why we use it, the benefits of RIP, how it is works, and how its implemented on RouterOS.
the recording is available on youtube (GLC NETWORKS CHANNEL): https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
This document contains an agenda and presentation slides for a webinar hosted by GLC Networks on IPv6 with Mikrotik RouterOS. The webinar covers an introduction to IPv6, how to enable and configure IPv6 on RouterOS, and a demonstration. It provides information on GLC Networks as an Indonesian training and consulting company, the trainer's background, and how to assign IPv6 addresses on RouterOS using SLAAC and DHCPv6 prefix delegation. Slides include comparisons of IPv4 and IPv6, IPv6 addressing rules, and assigning IPv6 addresses to clients.
in this webinar, we were discussing about a mikrotik feature that is called metarouter, which can allow us to create an independent virtual router instance. we start the presentation from the introduction of mikrotik and GLC, and then the metarouter. we also do demo and QA and the end of presentation.
the recording is available on youtube: https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
in this webinar, we were discussing about one important mikrotik feature that is firewall, with focus on filter table. we start the presentation from the introduction of mikrotik and firewall, and then the filter table. we also do demo and QA and the end of presentation.
the recording is available on youtube: https://www.youtube.com/channel/UCI611_IIkQC0rsLWIFIx_yg
Malibou Pitch Deck For Its €3M Seed Roundsjcobrien
French start-up Malibou raised a €3 million Seed Round to develop its payroll and human resources
management platform for VSEs and SMEs. The financing round was led by investors Breega, Y Combinator, and FCVC.
How Can Hiring A Mobile App Development Company Help Your Business Grow?ToXSL Technologies
ToXSL Technologies is an award-winning Mobile App Development Company in Dubai that helps businesses reshape their digital possibilities with custom app services. As a top app development company in Dubai, we offer highly engaging iOS & Android app solutions. https://rb.gy/necdnt
14 th Edition of International conference on computer visionShulagnaSarkar2
About the event
14th Edition of International conference on computer vision
Computer conferences organized by ScienceFather group. ScienceFather takes the privilege to invite speakers participants students delegates and exhibitors from across the globe to its International Conference on computer conferences to be held in the Various Beautiful cites of the world. computer conferences are a discussion of common Inventions-related issues and additionally trade information share proof thoughts and insight into advanced developments in the science inventions service system. New technology may create many materials and devices with a vast range of applications such as in Science medicine electronics biomaterials energy production and consumer products.
Nomination are Open!! Don't Miss it
Visit: computer.scifat.com
Award Nomination: https://x-i.me/ishnom
Conference Submission: https://x-i.me/anicon
For Enquiry: Computer@scifat.com
Preparing Non - Technical Founders for Engaging a Tech AgencyISH Technologies
Preparing non-technical founders before engaging a tech agency is crucial for the success of their projects. It starts with clearly defining their vision and goals, conducting thorough market research, and gaining a basic understanding of relevant technologies. Setting realistic expectations and preparing a detailed project brief are essential steps. Founders should select a tech agency with a proven track record and establish clear communication channels. Additionally, addressing legal and contractual considerations and planning for post-launch support are vital to ensure a smooth and successful collaboration. This preparation empowers non-technical founders to effectively communicate their needs and work seamlessly with their chosen tech agency.Visit our site to get more details about this. Contact us today www.ishtechnologies.com.au
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...The Third Creative Media
"Navigating Invideo: A Comprehensive Guide" is an essential resource for anyone looking to master Invideo, an AI-powered video creation tool. This guide provides step-by-step instructions, helpful tips, and comparisons with other AI video creators. Whether you're a beginner or an experienced video editor, you'll find valuable insights to enhance your video projects and bring your creative ideas to life.
Odoo releases a new update every year. The latest version, Odoo 17, came out in October 2023. It brought many improvements to the user interface and user experience, along with new features in modules like accounting, marketing, manufacturing, websites, and more.
The Odoo 17 update has been a hot topic among startups, mid-sized businesses, large enterprises, and Odoo developers aiming to grow their businesses. Since it is now already the first quarter of 2024, you must have a clear idea of what Odoo 17 entails and what it can offer your business if you are still not aware of it.
This blog covers the features and functionalities. Explore the entire blog and get in touch with expert Odoo ERP consultants to leverage Odoo 17 and its features for your business too.
An Overview of Odoo ERP
Odoo ERP was first released as OpenERP software in February 2005. It is a suite of business applications used for ERP, CRM, eCommerce, websites, and project management. Ten years ago, the Odoo Enterprise edition was launched to help fund the Odoo Community version.
When you compare Odoo Community and Enterprise, the Enterprise edition offers exclusive features like mobile app access, Odoo Studio customisation, Odoo hosting, and unlimited functional support.
Today, Odoo is a well-known name used by companies of all sizes across various industries, including manufacturing, retail, accounting, marketing, healthcare, IT consulting, and R&D.
The latest version, Odoo 17, has been available since October 2023. Key highlights of this update include:
Enhanced user experience with improvements to the command bar, faster backend page loading, and multiple dashboard views.
Instant report generation, credit limit alerts for sales and invoices, separate OCR settings for invoice creation, and an auto-complete feature for forms in the accounting module.
Improved image handling and global attribute changes for mailing lists in email marketing.
A default auto-signature option and a refuse-to-sign option in HR modules.
Options to divide and merge manufacturing orders, track the status of manufacturing orders, and more in the MRP module.
Dark mode in Odoo 17.
Now that the Odoo 17 announcement is official, let’s look at what’s new in Odoo 17!
What is Odoo ERP 17?
Odoo 17 is the latest version of one of the world’s leading open-source enterprise ERPs. This version has come up with significant improvements explained here in this blog. Also, this new version aims to introduce features that enhance time-saving, efficiency, and productivity for users across various organisations.
Odoo 17, released at the Odoo Experience 2023, brought notable improvements to the user interface and added new functionalities with enhancements in performance, accessibility, data analysis, and management, further expanding its reach in the market.
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid
IBM watsonx Code Assistant for Z, our latest Generative AI-assisted mainframe application modernization solution. Mainframe (IBM Z) application modernization is a topic that every mainframe client is addressing to various degrees today, driven largely from digital transformation. With generative AI comes the opportunity to reimagine the mainframe application modernization experience. Infusing generative AI will enable speed and trust, help de-risk, and lower total costs associated with heavy-lifting application modernization initiatives. This document provides an overview of the IBM watsonx Code Assistant for Z which uses the power of generative AI to make it easier for developers to selectively modernize COBOL business services while maintaining mainframe qualities of service.
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfVALiNTRY360
Salesforce Healthcare CRM, implemented by VALiNTRY360, revolutionizes patient management by enhancing patient engagement, streamlining administrative processes, and improving care coordination. Its advanced analytics, robust security, and seamless integration with telehealth services ensure that healthcare providers can deliver personalized, efficient, and secure patient care. By automating routine tasks and providing actionable insights, Salesforce Healthcare CRM enables healthcare providers to focus on delivering high-quality care, leading to better patient outcomes and higher satisfaction. VALiNTRY360's expertise ensures a tailored solution that meets the unique needs of any healthcare practice, from small clinics to large hospital systems.
For more info visit us https://valintry360.com/solutions/health-life-sciences
Most important New features of Oracle 23c for DBAs and Developers. You can get more idea from my youtube channel video from https://youtu.be/XvL5WtaC20A
Microservice Teams - How the cloud changes the way we workSven Peters
A lot of technical challenges and complexity come with building a cloud-native and distributed architecture. The way we develop backend software has fundamentally changed in the last ten years. Managing a microservices architecture demands a lot of us to ensure observability and operational resiliency. But did you also change the way you run your development teams?
Sven will talk about Atlassian’s journey from a monolith to a multi-tenanted architecture and how it affected the way the engineering teams work. You will learn how we shifted to service ownership, moved to more autonomous teams (and its challenges), and established platform and enablement teams.
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Paul Brebner
Closing talk for the Performance Engineering track at Community Over Code EU (Bratislava, Slovakia, June 5 2024) https://eu.communityovercode.org/sessions/2024/why-apache-kafka-clusters-are-like-galaxies-and-other-cosmic-kafka-quandaries-explored/ Instaclustr (now part of NetApp) manages 100s of Apache Kafka clusters of many different sizes, for a variety of use cases and customers. For the last 7 years I’ve been focused outwardly on exploring Kafka application development challenges, but recently I decided to look inward and see what I could discover about the performance, scalability and resource characteristics of the Kafka clusters themselves. Using a suite of Performance Engineering techniques, I will reveal some surprising discoveries about cosmic Kafka mysteries in our data centres, related to: cluster sizes and distribution (using Zipf’s Law), horizontal vs. vertical scalability, and predicting Kafka performance using metrics, modelling and regression techniques. These insights are relevant to Kafka developers and operators.
Measures in SQL (SIGMOD 2024, Santiago, Chile)Julian Hyde
SQL has attained widespread adoption, but Business Intelligence tools still use their own higher level languages based upon a multidimensional paradigm. Composable calculations are what is missing from SQL, and we propose a new kind of column, called a measure, that attaches a calculation to a table. Like regular tables, tables with measures are composable and closed when used in queries.
SQL-with-measures has the power, conciseness and reusability of multidimensional languages but retains SQL semantics. Measure invocations can be expanded in place to simple, clear SQL.
To define the evaluation semantics for measures, we introduce context-sensitive expressions (a way to evaluate multidimensional expressions that is consistent with existing SQL semantics), a concept called evaluation context, and several operations for setting and modifying the evaluation context.
A talk at SIGMOD, June 9–15, 2024, Santiago, Chile
Authors: Julian Hyde (Google) and John Fremlin (Google)
https://doi.org/10.1145/3626246.3653374
4. About Me
4
● Name: Achmad Mardiansyah
● Base: bandung, Indonesia
● Linux user since 1999
● Write first “hello world” 1993
● First time use PHP 2004, PHP OOP 2011.
○ Php-based web applications
○ Billing
○ Radius customisation
● Certified Trainer: Linux, Mikrotik, Cisco
● Teacher at Telkom University (Bandung, Indonesia)
● Website contributor: achmadjournal.com,
mikrotik.tips, asysadmin.tips
● More info:
http://au.linkedin.com/in/achmadmardiansyah
5. About GLCNetworks
● Garda Lintas Cakrawala (www.glcnetworks.com)
● Based in Bandung, Indonesia
● Scope: IT Training, Web/Application developer, Network consultant (Mikrotik,
Cisco, Ubiquity, Mimosa, Cambium), System integrator (Linux based
solution), Firewall, Security
● Certified partner for: Mikrotik, Ubiquity, Linux foundation
● Product: GLC billing, web-application, customise manager
5
6. prerequisite
● This presentation is not for beginner
● We assume you already know basic skills of programming and algorithm:
○ Syntax, comments, variables, constant, data types, functions, conditional, loop, arrays, etc
● We assume you already have experience to create a web-based application
using procedural method
6
8. Procedural PHP
● Code executed sequentially
● Easy to understand
● Faster to implement
● Natural
● Program lines can be very long
● Need a way to architect to:
○ Manage our code physically
○ Manage our application logic
8
<?php
define DBHOST
define DBUSER
$variable1
$variable2
if (true) {
code...
}
for ($x=0; $x<=100; $x++) {
echo "The number is: $x
<br>";
9. Basic: Constant vs Variable
● Both are identifier to represent
data/value
● Constant:
○ Value is locked, not allowed to be
changed
○ Always static: memory address is static
● Variable:
○ Static:
■ Memory address is static
○ Dynamic
■ Memory address is dynamic
■ Value will be erased after function
is executed
9
<?php
define DBHOST
define DBUSER
$variable1
$variable2
}
?>
10. Basic: static vs dynamic (non-static) variable
● Static variable
○ Memory address is static
○ The value is still keep after function is
executed
● Non-static variable
○ Memory address is dynamic
○ The value is flushed after execution
10
function myTest() {
static $x = 0;
echo $x;
$x++;
}
myTest();
myTest();
myTest();
11. Efficient code: using functions
1111
<?php
define DBHOST
define DBUSER
$variable1
$variable2
if (true) {
code...
}
for ($x=0; $x<=100; $x++) {
echo "The number is: $x
<br>";
}
1111
<?php
function calcArea () {
Code…
}
define DBHOST
define DBUSER
$variable1
$variable2
calcArea();
?>
before after
12. Efficient code: include
1212
<?php
function calcArea () {
Code…
}
define DBHOST
define DBUSER
$variable1
$variable2
calcArea();
?>
<?php
include file_function.php
define DBHOST
define DBUSER
$variable1
$variable2
calcArea();
?>
before after
15. We need more features...
● Grouping variables / functions -> so that it can represent real object
● Define access to variables/functions
● Easily extend current functions/group to have more features without losing
connections to current functions/group
15
17. ● Class is a group of:
○ Variables -> attributes/properties
○ Functions -> methods
● We call the class first, and then call
what inside (attributes/methods)
● The keyword “$this” is used when a
thing inside the class, calls another
thing inside the class
CLASS → instantiate→ object
To access the things inside the class:
$object->variable
$object->method()
OOP: Class and Object
17
<?php
class Fruit {
// Properties
public $name;
public $color;
// Methods
function set_name($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}
}
$apple = new Fruit();
$banana = new Fruit();
$apple->name='manggo';
$apple->set_name('Apple');
$banana->set_name('Banana');
echo $apple->get_name()."<br>";
echo $banana->get_name();
?>
18. OOP: inheritance
● Class can have child class
● Object from child class can access
things from parent class
● Implemented in many php framework
● This is mostly used to add more
functionality of current application
● Read the documentation of the main
class
18
<?php
class Fruit {
public $name;
public $color;
public function __construct($name,
$color) {
$this->name = $name;
$this->color = $color;
}
public function intro() {
echo "The fruit is {$this->name}
and the color is {$this->color}.";
}
}
class Strawberry extends Fruit {
public function message() {
echo "Am I a fruit or a berry?
";
}
}
$strawberry = new
Strawberry("Strawberry", "red");
$strawberry->message();
$strawberry->intro();
?>
19. OOP: method chain
● Object can access several method in
chains
● Similar to UNIX pipe functions
● For example: text processing with
various method
19
<?php
class fakeString {
private $str;
function __construct() {
$this->str = "";
}
function addA() {
$this->str .= "a";
return $this;
}
function addB() {
$this->str .= "b";
return $this;
}
function getStr() {
return $this->str;
}
}
$a = new fakeString();
echo $a->addA()->addB()->getStr();
?>
20. OOP: constructor
● Is a method that is executed
automatically when a class is called
20
<?php
class Fruit {
public $name;
public $color;
function __construct($name, $color) {
$this->name = $name;
$this->color = $color;
}
function get_name() {
return $this->name;
}
function get_color() {
return $this->color;
}
}
$apple = new Fruit("Apple", "red");
echo $apple->get_name();
echo "<br>";
echo $apple->get_color();
?>
21. OOP: destructor
● Is the method that is called when the
object is destructed or the script is
stopped or exited
21
<?php
class Fruit {
public $name;
public $color;
function __construct($name) {
$this->name = $name;
}
function __destruct() {
echo "The fruit is {$this->name}.";
}
}
$apple = new Fruit("Apple");
?>
22. OOP: access modifier
(attribute)
● Properties and methods can have
access modifiers which control where
they can be accessed.
● There are three access modifiers:
○ public - the property or method can be
accessed from everywhere. This is default
○ protected - the property or method can be
accessed within the class and by classes
derived from that class
○ private - the property or method can ONLY
be accessed within the class
22
<?php
class Fruit {
public $name;
protected $color;
private $weight;
}
$mango = new Fruit();
$mango->name = 'Mango'; // OK
$mango->color = 'Yellow'; // ERROR
$mango->weight = '300'; // ERROR
?>
23. OOP: access modifier
(method)
● Properties and methods can have
access modifiers which control where
they can be accessed.
● There are three access modifiers:
○ public - the property or method can be
accessed from everywhere. This is default
○ protected - the property or method can be
accessed within the class and by classes
derived from that class
○ private - the property or method can ONLY
be accessed within the class
23
<?php
class Fruit {
public $name;
public $color;
public $weight;
function set_name($n) {
$this->name = $n;
}
protected function set_color($n) {
$this->color = $n;
}
private function set_weight($n) {
$this->weight = $n;
}
}
$mango = new Fruit();
$mango->set_name('Mango'); // OK
$mango->set_color('Yellow'); // ERROR
$mango->set_weight('300'); // ERROR
?>
24. OOP: abstract
● Abstract classes and methods are
when the parent class has a named
method, but need its child class(es) to
fill out the tasks.
● An abstract class is a class that
contains at least one abstract method.
● An abstract method is a method that is
declared, but not implemented in the
code.
● When inheriting from an abstract class,
the child class method must be defined
with the same name, and the same or
a less restricted access modifier
●
24
<?php
abstract class Car {
public $name;
public function __construct($name) {
$this->name = $name;
}
abstract public function intro() :
string;
}
// Child classes
class Audi extends Car {
public function intro() : string {
return "German quality! $this->name!";
}
}
// Create objects from the child classes
$audi = new audi("Audi");
echo $audi->intro();
echo "<br>";
?>
25. OOP: trait
● Traits are used to declare methods
that can be used in multiple classes.
● Traits can have methods and abstract
methods that can be used in multiple
classes, and the methods can have
any access modifier (public, private, or
protected).
25
<?php
trait message1 {
public function msg1() {
echo "OOP is fun! ";
}
}
class Welcome {
use message1;
}
$obj = new Welcome();
$obj->msg1();
?>
26. OOP: static properties
● Attached to the class
● Can be called directly without instance
● Keyword “::”
● Calling inside the class, use keyword
self::
● From child class, use keyword parent
26
<?php
class pi {
public static $value=3.14159;
public function staticValue() {
return self::$value;
}
}
class x extends pi {
public function xStatic() {
return parent::$value;
}
}
//direct access to static variable
echo pi::$value;
echo x::$value;
$pi = new pi();
echo $pi->staticValue();
?>
27. OOP: static method
● Attached to the class
● Can be called directly without instance
● Keyword “::”
● Calling inside the class, use keyword
self::
● From child class, use keyword parent
27
<?php
class greeting {
public static function welcome() {
echo "Hello World!";
}
public function __construct() {
self::welcome();
}
}
class SomeOtherClass {
public function message() {
greeting::welcome();
}
}
//call function without instance
greeting::welcome();
new greeting();
?>
29. Several checklist on OOP
● Step back -> planning -> coding
● Design, design, design -> architecture
○ Its like migrating to dynamic routing
○ Class design
■ Attribute
■ Method
29
30. OOP myth /
● Its better to learn programming directly to OOP
● Using OOP means we dont need procedural
● OOP performs better
● OOP makes programming more visual. OOP != visual programming (drag &
drop)
● OOP increases reuse (recycling of code)
●
30