PHP СИМВОЛ СТРЕЛКА

Symbol arrow (->) in php is an operator used to access properties and methods of an object.

When we have an object instance, we can use "->" to access its public properties and methods. For example:

$person = new Person;
$person->name = 'John';
$person->sayHello();

In the example, we create an instance of the Person class and assign the name "John" to its public "name" property. Then we call the public "sayHello" method of the Person class using "->".

The "->" operator can also be used to access properties and methods of an object stored in a variable. For example:

$person = new Person;
$methodName = 'sayHello';
$person->$methodName();

This example, create an instance of the Person class and store it in the $person variable. Then we store the name of the "sayHello" method in the $methodName variable and call the method using "->".

Using "->" is a fundamental concept in object-oriented programming in PHP, and it allows us to access and manipulate data stored in objects.

[ПРАКТИКА] - Строим структуру своего PHP приложения + аутентификация

Операторы в PHP - Базовый курс PHP-7

PHP валидация полей формы

Реальное собеседование на Junior PHP разработчика

Почему все ненавидят PHP?

16 Функция header в PHP

Урок 14. PHP - ООП. Трейт (trait)

Реклама
Новое
Реклама