Categories
PHP

OOP Inheritance

One of the powerful concepts in object-oriented programming is inheritance. Inheritance allows a new class to be defined by extending the capabilities of an existing base class. PHP allows a new class to be created by extending an existing class with the extends keyword.

Categories
PHP

Static Variables and Methods

You can use the static keyword to declare class properties and methods. A static member can be accessed without having to create a new instance of the class. The instances of the class get the same value of a static variable because it belongs to the class, not the instance.

Categories
PHP

Class Constants

Learn how to define and use constants inside classes.

Categories
PHP

OOP Encapsulation and Visibility Modifiers

Encapsulation is just wrapping some data in an object. The term “encapsulation” is often used interchangeably with “information hiding”. PHP provides three visibility modifiers that you can use to control who can view and modify member variables as well as call member functions.

Categories
PHP

Class Constructor and Destructor

When an instance of a class is created the PHP engine executes the constructor method that builds the object with any existing properties and methods. And when the object is no longer needed or the script is finished executing, the PHP engine executes the destructor method and removes the object from the system’s memory.

Categories
PHP

Object Oriented Programming

Object-oriented programming assumes everything as an object. This tutorial covers how to declare, implement, and use classes.

Categories
PHP

Including external files

PHP uses four directives that can be used to include another PHP file in a currently running script.

Categories
PHP

Variable Scope

How to use use variables declared outside the function?

Categories
PHP

Arrow and Anonymous Functions

In this tutorial we’ll use and compare anonymous and arrow functions.

Categories
PHP

Passing variables by reference to a function

By default, variables are passed to functions by value. To pass variables by reference, prefix the variable with & (ampersand) character: &$var. Referencing with the ampersand can also be used when assigning variables.