Getting started with Learn PHP online. Part II. OOP


Contents:


What is OOP?
In this lesson we will describe what is объектно-ориентированное программирование
Classes and objects
In this lesson we will define what concepts mean класс and ...
Encapsulation, polymorphism, inheritance
Consider the basic principles of OOP, which are инкапсуляция, наследование и полимор...
Defining classes in PHP
In this lesson we will describe how to create класс in PHP. To cr...
Creating objects in PHP
In order to create instances of a class, you must use the operator new together with t...
The instanceof operator
Operator instanceof It is intended to check whether the object is an instance of a par...
Class Properties
Свойства класса - this переменные ,...
Appealing to object properties
In order to access the properties of objects, use the operator ->. It is written af...
Methods of classes/of objects
In previous lessons, we determined only свойства classes and used ...
Type casting: objects
Consider the basic rules that apply to casting types involving a data type Object . ...
$ This variable
Variable $this is a special variable that is used to access a class object from within...
Public and private
In previous lessons, we used the scope public access to the properties and methods of ...
Inheritance of classes
In this lesson, we'll look at how class inheritance is implemented in PHP. Наследов...
Protected - Protected properties and methods
Until now, we only used private and public access for class properties a...
Assigning Objects
Consider the issue of assigning objects. The assignment operator = works with objects,...
Cloning Objects
Клонирование object is to create another instance of the class tha...
Magic methods: constructor and destructor
In this lesson we will talk about some, so-called, магических методах
Static properties
Статические class properties are properties that can be accessed w...
Class Constants
Within classes, you can define константы , which will belong only to...
Static methods
Статические методы are methods that you can call without creating a...
Accessing the class using self
To access class constants, static properties, and static class methods from within the class itself ...
Appeal to the parent class
When defining a child class, to access constants, static properties, and methods of the parent class...
Appeal to the constructor of the parent class
When you call the constructor of a child class, конструктор родительского класса
The magic methods __clone, __get, __set
In this lesson, consider the magic methods __clone, __get, __set
Magic methods __call, __callStatic
In this lesson we will look at magic methods __call, __callStatic Meth...
Other magical methods
In this lesson, consider the other magic methods: __isset(), __unset(), ...
Magic constants and useful functions
Consider the magic class constants and some useful functions for classes. Constant _...
Iterating an object
PHP allows итерировать object properties with help foreach
Abstract classes and methods
Абстрактный класс - This is a class for which its instances can no...
Final classes and methods
Keyword final before class definition means that this class can not have child classes...
The static keyword
Keyword static Used to access static properties and methods from the context of the cl...
Interfaces
Интерфейсы are structures that describe what constants and methods...
Implementing interfaces
For реализации interface, you must write down the keyword i...
Interface Inheritance
Interfaces support inheritance. To do this, the keyword is also used extends. Note tha...
Type declaration
When using objects as аргументов функций you can fix the name of th...
What is an exception?
Исключение is an action that does not fit the application. Excepti...
Catching Exceptions
In order to catch the thrown exception, the construct is used [php]try {   // some code, we ...
Creating your exception classes
To create your exception class, you must inherit it from an existing exception class, for example fr...
Auto-load classes
As a rule, separate classes are placed in separate files of the same name. For example, in a file
OOP test
The class differs from the object in that a) a class is a variable, an o...