The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Not getting it? Reply To: Not getting it?

Ilan Firsov

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;