Class A{
private $name;
private $id;
public function setName($name) {
$this–>name = $name;
return $this;
}
public function getName() {
return $this–>name;
}
public function setId($id) {
$this–>id = $id;
return $this;
}
public function getId() {
return $this–>id;
}
}
เวลาเรียกใช้
Code (PHP)
$test = new A();
$test->setId(1)->setName('Fredrick');