Home › Forums › Back End › Not getting it? › Reply To: Not getting it?
September 16, 2014 at 11:41 pm
#183340
Ilan Firsov
Participant
First thing you don’t have a constructor that takes arguments, so the line $animal = new animal('dog');
does nothing with the argument you provided
Second thing is that when you call the name
function without arguments it defaults to name=” which is then returned.
I’d do something like this:
function name ($type) {
if(!empty($type)) {
$this->name = $type;
return $this->name;
} else {
return $this->name;
}
}