KEMBAR78
Beginning OOP in PHP | PDF
Beginning OOP in
PHP
OpenWest - May 7, 2015
David Stockton
David Stockton

VP of Technology, i3logix

Denver, CO
Coding in PHP for over 17 years
Organizer of the Front Range PHP User Group for 5 years
Board of Directors, Front Range Web Developer Assoc.
@dstockto
http://davidstockton.com
http://tddftw.com
https://www.youtube.com/user/dstockto/videos
#phpmentoring
#phpstudygroup
What we’ll talk about
• Classes
• Objects
• Interfaces
• Inheritance
• Methods
• Properties
• Visibility
Modifiers
• Static
• Constructors
Why bother with OOP?
Lack of Abstraction
Problems with Procedural Code
Why bother with OOP?
Data stores as structure
Problems with Procedural Code
Why bother with OOP?
Functions are global and
not related to structures
Problems with Procedural Code
What is a class?
A blueprint
Simple Class
Defines state
What does a class do?
What are properties?
Information / Data on an
object
What does a class do?
Defines
behavior
What are methods?
Behaviors on a class
What’s an object?
An instance of a class
Constructor
One of PHP’s “magic” methods
__construct
Used to initialize the 

properties of the object
Visibility Modifiers
Public
Protected
Private
Public
Method or property is available to anything
From anywhere
Protected
Property or method available 

within the class or class’s inheritance 

structure (both ways)
Private
Method or property only
available within the object
Inheritance
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
“is a”
What is encapsulation?
What is an interface?
Commonly named
functionality
What is an interface?
A contract
between caller and callee
Why are interfaces
important?
Allows common language and API for 

different classes
Static
Method or class available at
Class level, no object needed
Changes affect all instances of
the class
Abstract Classes
Provides functionality to child classes
Cannot be instantiated
Questions?
Please
rate
this
talk
https://joind.in/13950

Beginning OOP in PHP