This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Objects in PHP Forum

View Course » View Exercise

735 points
Picture
Submitted by
Oladimeji Gbolahan
almost 3 years ago

HELP, PLEASE!!!!! DID YOU ADD THE PHP TAGS

please this is my code but i cant seem to figure out what i have done wrong please help me out

<?php 
        class Dog {
            public $numLegs = 4;
            public $name;
            public function __construct($name){
           $this->name=$name;     
            }
        }
        ?>

2 votes

permalink

I think I can help, but I need to know which exercise you are on.

366 points
5361354f9c4e9d42bf000979_559338498
Submitted by
programmer.exe
almost 3 years ago


2 votes

permalink

Looks good so far, just incomplete. You still need to do something like

$dog1 = new Dog("dog1sName");

outside of the class. Then echo back the name.

549 points
510e8af0cb6718209c007539_548164927
Submitted by
Chris Smith
almost 3 years ago


1 vote

permalink

This workt for me.
<?php
class Dog {
public $numLegs = 4;
public $name;
public function __construct($name);
$this->name $name;
}
?>

225 points
543aee4852f8639b7b000413_724188441
Submitted by
Janssen gevelmontage
over 2 years ago