Constructor

class Student {
    public function \_\_construct($name) {
        $this->name = $name;
    }
      public function print() {
        echo "Name: " . $this->name;
    }
}
$alex = new Student("Alex");
$alex->print();    # => Name: Alex
Comments