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?


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

Ah __construct is what is required when using new.

    class animal {
        public function __construct($name) {
           $this->name = $name;

        public function name() {
            return $this->name;

    $animal = new animal('dog');

    //Output: string(3) "dog"

I just figured I could do this with only one function.