I'm working on a personal project in PHP and like most classes that are built, I require getter/setter functions.
I had a thought and did some research but couldn't find an answer. Instead of defining two functions - one get and one set - why couldn't they just be handled by a single function?
function myVar ($newVar = NULL) {
if(isset($newVar)) {
$this->var = $newVar;
} else {
return $this->var;
}
}
Are there any downsides to this that I may not be seeing?