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

Objects in PHP Forum

View Course » View Exercise

362 points
542a0d6352f8630cfa000b92_818429714
Submitted by
Damji Heo
almost 3 years ago

Oops, try again. Did you create an '$numLegs' property?

I don't know what's wrong with this coding:
<?php
class Dog {
public $numlegs = 4;

public $name;

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

     ?>

3 votes

permalink

i think you should write $numLegs instead of $numlegs :) the L letter must be Capital

850 points
547dcfd29c4e9d6a5700238c_768950481
Submitted by
Sarah
almost 3 years ago

1 Comment

542a0d6352f8630cfa000b92_818429714 Damji Heo almost 3 years ago

I put $numLegs but still same.


1 vote

permalink

here's my code mine is working :) also it's like yours!!

        <!-- Your code here -->
    <?php
        class Dog {
            public $numLegs = 4;
            public $name;

            public function __construct($name) {
                $this->name = $name;
            }                    
        }
    ?>

i know it maybe stupid if i say this! but also once i had such problem, and my code didn't work, and by accident i realized i shouldn't remove the <!--comment--> on the code! and i had to let it stay in the code! then after my code worked and i started the next exercise!

850 points
547dcfd29c4e9d6a5700238c_768950481
Submitted by
Sarah
almost 3 years ago

1 Comment

54cffb8c51b887b5bb0011aa_557477897 Ali almost 3 years ago

idk what the heck is that i tried typing $numLegs didnt work than i copy / past from instructions and it worked although they were exactly the same !!


0 votes

permalink

are your codes other than the one you showed here ok? Sometimes, I noticed that when some other codes are not ok, codecademy just shows some other message. Like, I had mispelled public and I got the message "did you remember to put the <?php and ?> tags?"

LOL.

646 points
Picture
Submitted by
sunoy14
almost 3 years ago


0 votes

permalink

you guys can check out mine if u like,

my code :

    <?php
    class Dog{
        public $numLegs = 4;
        public $name; 

    public function __construct($name){
        $this->name = $name;
        }
    public function bark(){

        }
    public function greet(){

        }    
    }    
    ?><!-- Your code here -->

Good luck :)

1061 points
9aafefbc0880681c07d2a345dbef8b5f?s=140&d=retro
Submitted by
Sigma18
about 2 years ago