Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Below is another example

Code Block
<?php

class Car {
  public $make;
  public $model;
  public $year;

  public function getMakeAndModel() {
    return $this->make . ' ' . $this->model;
  }
}

$car = new Car();
$car->make = "Toyota";
$car->model = "Camry";
$car->year = 2020;

echo $car->getMakeAndModel();
//:
    def __init__(self, make, model, year):
        self.make = make
        self.model = model
        self.year = year

    def get_make_and_model(self):
        return f'{self.make} {self.model}'

car = Car("Toyota", "Camry", 2020)
print(car.get_make_and_model())
# Output: Toyota Camry

?>