1 Object Oriented PHP Essential Constructs m1 Slides
1 Object Oriented PHP Essential Constructs m1 Slides
Essential Constructs
Daryl K Wood
@datashuttle |
www.datashuttle.netwww.linkedin.com/in/datashuttle
Course Overview
Introduction
Knowledge prerequisite
Installed software requirement
Goals for this module
Knowledge Prerequisites
A Naming Collision
A variable in your application can be redefined later by use of another library or
extension.
Best Practice: Encapsulate your code in a protected scope called a class.
The Class Construct
What is a class
Class encapsulation and scope
Class properties (variables)
Class methods (functions)
Class constants
Best practices
What Is a Class?
A container of information
Provides access control to its
contents
Class Encapsulation and Scope
A graphical representation of a
class container (UML)
Contains class member properties
and methods
Encapsulation
Encapsulation is the packing of data and functions
into a single component.
It allows selective hiding of properties and methods
in an object by building an impenetrable wall to
protect the code from accidental corruption.
Source: wikipedia.org
class <ClassName> {}
Class Properties
Prefixing the property declaration with one of three visibilities: public, protected or
private.
Setting default values.
Class Properties Summary
Class properties
Visibility
Assigning default values
Best practices
Slide Deck Clip Break
Class Methods
Class methods
Visibility
Scope
Best practices
IDE place holder
Class Constants
Class constants
Visibility as it relates to constants
Defining a default value
Scope
Best practices
IDE place holder
The Form Class