2

I am finally grasping most of the syntax in php but examples like this one I do not seem to understand what it means:

   if ( $matches->match_is_editable( $ts ) )

This is what I understad:

"$matches" is a variable

"->" means that is part of the same object but confused how its supposed to relate to the next part

"match_is_editable" is a function

"($ts)" is a variable called to work in inside that function

can you please correct where I am wrong? Will be highly appreciated

Kevin
  • 41,694
  • 12
  • 53
  • 70

1 Answers1

5
$matches->match_is_editable( $ts )

The -> accesses an object's method (what we call functions when they belong to objects) or property. This means two things:

  1. $matches is a handle to an object. Somewhere earlier in the code you will find $matches = new ClassName() (if ClassName is the name of the object's class)
  2. match_is_editable must be a method or a property in ClassName

In this case, since it takes the argument $ts, we can deduce that it's not a property, but a method. Here is what the class might look like:

Class ClassName{
    public function match_is_editable($arg){
        ...
    }
}

So the top line means: Access the object referred to by $matches and execute its match_is_editable method, passing it the argument $ts.

BeetleJuice
  • 39,516
  • 19
  • 105
  • 165