Several errors in PHP about OOP

I use XAMPP to access localhost. I have an error in index.php.

Screenshot of error:

Error

I have $name and $age defined in set_name() and set_age. Please check index.php:

<?php

class Pet {
    public $name;
    public $age;    

    // get() and set() functions for name
    function set_name($name) {
        $this->name = $name;
    }
    function get_name() {
        return $this->$name;
    }

    // get() and set() functions for age
    function set_age($age) {
        $this->age = $age;
    }
    function get_age() {
        return $this->$name;
    }
}

$cat = new Pet();
$cat->set_age(24);
$cat->set_name("Toby");

echo $cat->get_name() + ", " + $cat->get_age();

Answer

You need constructor for your classes and don’t do the makeSound method in your Pet class static. Try this:

public Cat(){
  makeSound(sound);
}

public Dog(){
  makeSound(sound);
}