This document discusses object-oriented programming (OOP) in PHP. It defines key OOP concepts like classes, objects, methods, and inheritance. It provides examples of creating classes and objects in PHP, and using concepts like constructors, multiple class instances, visibility, and building objects from scratch. The document aims to explain OOP and related terminology to help programmers transition to an object-oriented approach in PHP.
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.
Abstraction, Encapsulation, Polymorphism, Interfaces and Scope: whether you’ve been programming in PHP for years or are just starting your journey, these terms can be overwhelming. 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.
Real life examples of Object-Oriented terminology in a way that makes sense and allows you to utilizing OOP immediately.
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 utilize object-oriented programming (OOP) immediately.
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.
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.
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.
The recent Project of the Month on SourceForge, XOOPS (http://www.xoops.org) was designed from the very beginning as an object-oriented CMS, which is even reflected in its name: eXtensible Object Oriented Portal System. Michael will present the OOP oriented architecture of XOOPS, and show how OOP makes development of XOOPS modules easy and fun, promotes reuse of code, while keeping GUI consistent across all modules.
Demystifying Object-Oriented Programming - PHP UK Conference 2017Alena 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.
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.
Abstraction, Encapsulation, Polymorphism, Interfaces and Scope: whether you’ve been programming in PHP for years or are just starting your journey, these terms can be overwhelming. 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.
Real life examples of Object-Oriented terminology in a way that makes sense and allows you to utilizing OOP immediately.
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 utilize object-oriented programming (OOP) immediately.
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.
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.
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.
The recent Project of the Month on SourceForge, XOOPS (http://www.xoops.org) was designed from the very beginning as an object-oriented CMS, which is even reflected in its name: eXtensible Object Oriented Portal System. Michael will present the OOP oriented architecture of XOOPS, and show how OOP makes development of XOOPS modules easy and fun, promotes reuse of code, while keeping GUI consistent across all modules.
Demystifying Object-Oriented Programming - PHP UK Conference 2017Alena 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.
To better understand the behavior of servlets, let’s take a look at the life cycle of servlets.
A servlet is basically a small Java program that runs within a Web server. It can receive requests from clients and return responses. The whole life cycle of a servlet breaks up into 3 phases:
• Initialization: A servlet is first loaded and initialized usually when it is requested by the corresponding clients. Some websites allow the users to load and initialize servlets when the server is started up so that the first request will get responded more quickly.
• Service: After initialization, the servlets serve clients on request, implementing the ap- plication logic of the web application they belong to.
• Destruction: When all pending requests are processed and the servlets have been idle for a specific amount of time, they may be destroyed by the server and release all the resources they occupy.
More specifically, the behavior of a servlet is described in javax.servlet.Servlet interface, in which the following methods are defined:
• public void init(ServletConfig config) throws ServletException
This method is called once when the servlet is loaded into the servlet engine, before the servlet is asked to process its first request.
The init method has a ServletConfig parameter. The servlet can read its initialization arguments through the ServletConfig object. How the initialization arguments are set is servlet engine dependent but they are usually defined in a configuration file.
A typical example of an initialization argument is a database identifier. A servlet can read this argument from the ServletConfig at initialization and then use it later to open a connection to the database during processing of a request:
private String databaseURL;
public void init(ServletConfig config) throws ServletException { super.init(config);
databaseURL = config.getInitParameter("database");
}
• public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
This method is called to process a request. It can be called zero, one or many times until the servlet is unloaded.
Once a servlet is loaded, it remains in the server’s memory as a single object instance. Thereafter, the server invokes the servlet to handle a request using a simple, lightweight method invocation. Unlike with CGI, there’s no process to spawn or interpreter to invoke, so the servlet can begin handling the request almost immediately. Multiple, concurrent requests are handled by separate threads, so servlets are highly scalable.
Servlets are naturally enduring objects. Because a servlet stays in the server’s memory as a single object instance, it automatically maintains its state and can hold on to external resources, such as database connections, that may otherwise take several seconds to establish. The following servlet presents information about how many times it has been accessed:
To better understand the behavior of servlets, let’s take a lo
4. Use the AM for posting within scientific collaboration networks (SCNs). For a detailed description of our policy on posting to SCNs, please see our Web Posting Guidelines (https://publishing.aip.org/authors/web-posting-guidelines).
5. Reprint the Version of Record (VOR) in print collections written by the Author, or in the Author’s thesis or dissertation. It is understood and agreed that the thesis or dissertation may be made available electronically on the university’s site or in its repository and that copies may be offered for sale on demand.
6. Reproduce copies of the VOR for courses taught by the Author or offered at the institution where the Author is employed, provided no fee is charged for access to the Work.
7. Use the VOR for internal training and noncommercial business purposes by the Author’s employer.
8. Use the VOR in oral presentations made by the Author, such as at conferences, meetings, seminars, etc., provided those receiving copies are informed that they may not further copy or distribute the Work.
9. Distribute the VOR to colleagues for noncommercial scholarly use, provided those receiving copies are informed that they may not further copy or distribute the Work.
10. Post the VOR to their personal web page or their employer’s web page 12 months after publication by AIP Publishing.
11. Deposit the VOR in an institutional or funder-designated repository 12 months after publication by AIP Publishing.
12. Update a prior posting with the VOR on a noncommercial server such as arXiv, 12 months after publication by AIP Publishing.
Author Warranties
Each Author and Copyright Owner represents and warrants to AIP Publishing the following:
1. The Work is the original independent creation of each Author and does not infringe any copyright or violate any other right of any third party.
2. The Work has not been previously published and is not being considered for publication elsewhere in any form, except as a preprint on a noncommercial server such as arXiv, or in a thesis or dissertation.
3. Written permission has been obtained for any material used from other sources and copies of the permission grants have been supplied to AIP Publishing to be included in the manuscript file.
4. All third-party material for which permission has been obtained has been properly credited within the manuscript.
5. In the event that the Author is subject to university open access policies or other institutional restrictions that conflict with any of the rights or provisions of this License, such Author has obtained the necessary waiver from his or her university or institution.
This License must be signed by the Author(s) and, in the case of a Work Made for Hire, also by the Copyright Owners. One Author/Copyright Owner may sign on behalf of all the contributors/owners only if they all have authorized the signing, approved of the License, and agreed to be bound by it. The signing Author and, in the case of a Work Made for Hire, the signing Copyright Owne
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
2. PHP => Object Oriented
• With PHP 5, an object oriented approach is the preferred
pattern.
• Libraries are evolving toward OOP.
3. Object Oriented Programming
(OOP)
Object-oriented programming (OOP) is a programming
paradigm that represents concepts as "objects" that
have data fields (attributes that describe the object) and
associated procedures known as methods. Objects,
which are usually instances of classes, are used to
interact with one another to design applications and
computer programs.
http://en.wikipedia.org/wiki/Object-oriented_programming
4. Definitions
• Class - a template - Dog
• Method - A defined capability of a class - bark()
• Object or Instance - A particular instance of a class -
Lassie
Image CC-By 2.0: https://www.flickr.com/photos/dinnerseries/235704750
5. Terminology: Class
Defines the abstract characteristics of a thing (object), including
the thing’s characteristics (its attributes, fields, or properties)
and the thing’s behaviors (the things it can do, or methods,
operations, or features). One might say that a class is a
blueprint or factory that describes the nature of something. For
example, the class Dog would consist of traits shared by all
dogs, such as breed and fur color (characteristics), and the
ability to bark and sit (behaviors).
6. Terminology: Instance
One can have an instance of a class or a particular object.
The instance is the actual object created at runtime. In
programmer jargon, the Lassie object is an instance of
the Dog class. The set of values of the attributes of a
particular object is called its state. The object consists of
state and the behavior that is defined in the object’s class.
Object and Instance are often used interchangeably.
7. Terminology: Method
An object’s abilities. In language, methods are verbs. Lassie,
being a Dog, has the ability to bark. So bark() is one of Lassie’s
methods. She may have other methods as well, for example
sit() or eat() or walk() or save_timmy(). Within the program,
using a method usually affects only one particular object; all
Dogs can bark, but you need only one particular dog to do the
barking.
Method and Message are often used interchangeably.
22. Object Life Cycle
• Objects are created, used and discarded.
• We have special blocks of code (methods) that get called
- At the moment of creation (constructor)
- At the moment of destruction (destructor)
• Constructors are used a lot.
• Destructors are seldom used.
23. Constructor
The primary purpose of the constructor is to set up some
instance variables to have the proper initial values when the
object is created.
24. class PartyAnimal {
function __construct() {
echo("Constructedn");
}
function something() {
echo("Somethingn");
}
function __destruct() {
echo("Destructedn");
}
}
echo("--Onen");
$x = new PartyAnimal();
echo("--Twon");
$y = new PartyAnimal();
echo("--Threen");
$x->something();
echo("--The End?n");
--One
Constructed
--Two
Constructed
--Three
Something
--The End?
Destructed
Destructed
party.php
25. Many Instances
• We can create lots of objects - the class is the template
for the object.
• We can store each distinct object in its own variable.
• We call this having multiple instances of the same class.
• Each instance has its own copy of the instance variables.
26. class Hello {
protected $lang; // Only accessible in the class
function __construct($lang) {
$this->lang = $lang;
}
function greet() {
if ( $this->lang == 'fr' ) return 'Bonjour';
if ( $this->lang == 'es' ) return 'Hola';
return 'Hello';
}
}
$hi = new Hello('es');
echo $hi->greet()."n";
Hola
hello.php
27. Definitions
• Class - a template - Dog
• Method or Message - A defined capability of a class -
bark()
• Object or Instance - A particular instance of a class -
Lassie
• Constructor - A method which is called when the
instance / object is created
29. Inheritance
• When we make a new class we can reuse an existing
class and inherit all the capabilities of an existing class
and then add our own little bit to make our new class
• Another form of store and reuse
• Write once - reuse many times
• The new class (child) has all the capabilities of the old
class (parent) - and then some more
31. class Hello {
protected $lang;
function __construct($lang) { ... }
function greet() { ... }
}
class Social extends Hello {
function bye() {
if ( $this->lang == 'fr' ) return 'Au revoir';
if ( $this->lang == 'es' ) return 'Adios';
return 'goodbye';
}
}
$hi = new Social('es');
echo $hi->greet()."n";
echo $hi->bye()."n";
Hola
Adios
goodbye.php
32. Definitions
• Class - a template - Dog
• Method or Message - A defined capability of a class -
bark()
• Object or Instance - A particular instance of a class -
Lassie
• Constructor - A method which is called when the instance
/ object is created
• Inheritance - the ability to take a class and extend it to
make a new class
33. Visibility
Class member variables also have scope.
• Public – can be accessed outside the class, inside the
class, and in derived classes
• Protected – can be accessed inside the class, and in
derived classes
• Private – can only be accessed inside the class (i.e. private
variables are not visible in derived classes)
http://www.php.net/manual/en/language.oop5.visibility.php
34. class MyClass
{
public $pub = 'Public';
protected $pro = 'Protected';
private $priv = 'Private';
function printHello()
{
echo $this->pub."n";
echo $this->pro."n";
echo $this->priv."n";
}
}
$obj = new MyClass();
echo $obj->pub."n"; // Works
echo $obj->pro."n"; // Fatal Error
echo $obj->priv."n"; // Fatal Error
$obj->printHello(); // Shows Public, Protected and Private
Public
Public
Protected
Private
visibility.php
35. class MyClass2 extends MyClass
{
function printHello()
{
echo $this->pub."n";
echo $this->pro."n";
echo $this->priv."n"; // Undefined
}
}
echo("--- MyClass2 ---n");
$obj2 = new MyClass2();
echo $obj2->pub."n"; // Works
$obj2->printHello(); // Shows Public, Protected, Undefined
--- MyClass2 ---
Public
Public
Protected
(false)
36. Building an Object from
Scratch
• Sometimes a developer will prefer to make an object with
public key-value pairs rather than an array.
• Use where appropriate…
37. $player = new stdClass();
$player->name = "Chuck";
$player->score = 0;
$player->score++;
print_r($player);
class Player {
public $name = "Sally";
public $score = 0;
}
$p2 = new Player();
$p2->score++;
print_r($p2);
stdClass Object
(
[name] => Chuck
[score] => 1
)
Player Object
(
[name] => Sally
[score] => 1
)
scratch.php
38. Summary
• Object Oriented programming is a very structured approach to
code reuse.
• There is a trend away from global function names and toward
OO.
• We can group data and functionality together and create
many independent instances of a class.
39. Acknowledgements / Contributions
These slides are Copyright 2010- Charles R. Severance
(www.dr-chuck.com) as part of www.wa4e.com and made
available under a Creative Commons Attribution 4.0 License.
Please maintain this last slide in all copies of the document to
comply with the attribution requirements of the license. If you
make a change, feel free to add your name and organization
to the list of contributors on this page as you republish the
materials.
Initial Development: Charles Severance, University of Michigan
School of Information
Insert new Contributors and Translators here including names
and dates
Continue new Contributors and Translators here
40. Additional Source Information
• Snowman Cookie Cutter" by Didriks is licensed under CC BY
https://www.flickr.com/photos/dinnerseries/23570475099
• Photo from the television program Lassie. Lassie watches as Jeff (Tommy Rettig) works on his bike is Public
Domain
https://en.wikipedia.org/wiki/Lassie#/media/File:Lassie_and_Tommy_Rettig_1956.JPG
Editor's Notes
Note from Chuck. Please retain and maintain this page as you remix and republish these materials. Please add any of your own improvements or contributions.