-11

This is a very simple question, I'm trying to learn PHP and C++ and in both languajes I've see this -> , i kinda get the meaning,is like an asignation operator? but I haven't find the right answer.

Thanks a lot for your help and sorry if the question is too simple, i've searched far and wide in google but have not got a clear answer

Enrique26
  • 23
  • 3

2 Answers2

0

It allows you to access properties on an object;

In PHP

class Car {
     public $make;
     public $model;

     public function setMake($make) {
          $this->make = $make;
     }

     public function setModel($model) {
          $this->model = $model;
     }

     public function getMake() {
          return $this->make;
     }

     public function getModel() {
          return $this->model;
     }

}

$car = new car();
$car->setMake("BMW");
$car->setModel("Three Series");

echo "Make: " . $car->getMake() . " Model: " . $car->getModel();
SheppardDigital
  • 3,165
  • 8
  • 44
  • 74
0

The object operator, "->", is used in object scope to access methods and properties of an object.

Santosh Patel
  • 549
  • 2
  • 13