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

Objects in PHP Forum

View Course » View Exercise

425 points
8cc2c6e533dcc092bc9c6cb4081b0b8b?s=140&d=retro
Submitted by
Inconnu210_50acf779740c11a94a0003fe_
almost 3 years ago

Hey, your 'new' cat ought to be called 'CodeCat'! - 9 Challenge Time

I don't know my error but my code send me that error "Hey, your 'new' cat ought to be called 'CodeCat'!". I search answers on others topics but I have the same error...
Anyone can help me, please ?

My code :

   <?php
      // Your code here
      class Cat {
          public $isAlive = true;
          public $numLegs = 4;
          public $name;

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

          public function meow() {
              return "Meow meow";
          }
      }

      $cat1 = new Cat($name = "Codecat");
      echo $cat1->meow();
    ?> 

2 votes

permalink

Try writing CodeCat, both capital Cs.

562 points
372c0e891ace699b08e836b13dfeead7?s=140&d=retro
Submitted by
Rvervuurt
almost 3 years ago

1 Comment

8cc2c6e533dcc092bc9c6cb4081b0b8b?s=140&d=retro Inconnu210_50acf779740c11a94a0003fe_ almost 3 years ago

I'm stupid... Thanks :D


0 votes

permalink

<?php
class cat
{
public $isAlive=true;
public $numLegs="4";
public $name;

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

          public function meow()
          {
            return "Meow meow";  
          }
      }

      $cat1 = new Cat($name = "CodeCat");
      echo $cat1->meow();
    ?>

348 points
3218c3bde79dd329d19b5ec470f2a410?s=140&d=retro
Submitted by
Davo Mkrtchyan
almost 3 years ago