What is the purpose of return'ing $this when setting vars in the model
Posted
by TaMeR
on Stack Overflow
See other posts from Stack Overflow
or by TaMeR
Published on 2010-03-20T01:07:25Z
Indexed on
2010/03/20
1:11 UTC
Read the original article
Hit count: 347
I am a self thought hobby programmer and therefore don't have the fundamentals always down the way you professionals do. So please excuse me if this is basic.
What is the purpose or benefit of return'ing $this when setting vars in the model. I have seen this done in other places too but cant figure this out.
Sample code:
public function setAlias($Alias){
$this->_Alias = (string) $Alias;
return $this;
}
public function getAlias(){
return $this->_Alias;
}
© Stack Overflow or respective owner