php setter getter

Solutions on MaxInterview for php setter getter by the best coders in the world

showing results for - "php setter getter"
Francesco
25 Jan 2019
1class MyClass {
2    private $firstField;
3    private $secondField;
4
5    public function getFirstField() {
6        return $this->firstField;
7    }
8    public function setFirstField($x) {
9        $this->firstField = $x;
10    }
11    public function getSecondField() {
12        return $this->secondField;
13    }
14    public function setSecondField($x) {
15        $this->secondField = $x;
16    }
17}
18