what is passed with the $this parameter ?

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
hrnsykk
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Oct 01, 2020 12:44 am

Fri Oct 30, 2020 3:22 am

Hello Guys,

I came across the following code today while doing a code review.
The new instance pass the $this parameter, but I don't never see this variable in the class.

What does $this parameter pass to the Select instance ?

Code: Select all

 public function select(array $columns = ['*']): Statement\Select
    {
        return new Statement\Select($this, $columns);
    }
simonbrahan
php-forum Fan User
php-forum Fan User
Posts: 90
Joined: Mon Jun 08, 2020 2:00 am
Contact:

Sat Oct 31, 2020 7:11 am

If this code is within a class, "$this" refers to the current instance of the class. You can read a bit more about it here
Post Reply