0

many times I've seen this symbol ->

What is it? seems a logical operator or something

Complete example:

get_categories->category_count

2 Answers2

0

It's called the object operator.

For example:

$myObject = new stdClass();
$myObject->Hello = "world";

echo $myObject->Hello; //Returns world

You can also use this operator to call properties or methods from classes. For example:

Class MyClass {

  public function hello(){
      return "world";
  }

}

echo (new MyClass())->hello(); //Returns world
Daan
  • 12,099
  • 6
  • 34
  • 51
0

It is called as PHP object operator (T_OBJECT_OPERATOR).

Example:

$car = new Car();
$car->color = 'Red';
echo $car->color; // returns the color of the car.
Nikhil
  • 1,450
  • 11
  • 24