1/18
PHP OOP
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Object-Oriented Programming (OOP)
is a programming model that is based on the concept of classes and objects.
Class
is a self-contained, independent collection of variables and functions which work together to perform one or more specific tasks.
acts as template or blueprint from which individual objects can be created.
Object
are individual instances of a class.
class
A class can be declared using the ____ keyword, followed by the name of the class, and a pair of curly braces {}.
Properties, Methods
Variables within a class are called _____, while functions are called ______.
PascalCase
Class names are also conventionally written in ________
i.e. each concatenated word starts with an uppercase letter
(e.g. MyClass).
arrow symbol (->)
is an OOP construct that is used to access contained properties and methods of a given object.
$this
The pseudo-variable that provides a reference to the
calling object.
Constructor __construct()
allows us to initialize the object’s properties upon creation of the object.
Constructor
is invoked automatically every time you create an object.
Destructor
is invoked automatically every time you createa __destruct() function.
Access Modifiers
When working with classes, you can even restrict access to its properties and methods using the visibility keywords for greater control.
Public
a public property or method can be accessed anywhere within or outside of class. Default in PHP
Protected
a protected property or method can only be accessed within the class itself or in inherited classes.
Private
a private property or method is accessible only within the class that defines it.
extends
Classes can inherit the properties and methods of another class
using the _______ keyword.
constant
fixed in compile-time variable that cannot be changed at runtime
static
fixed in compile time variable that can be changed during runtime
Valorant class: Initiator
This class inherits the ability to INITIATE a site with a method of constructing information and destructing opposing team.