-1

I start learning PHP.

What's the problem with this code?

        <?php

          class Cat
          {
              public $isAlive= true;
              public $numLegs=4;
              public $name="";

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

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

          $cat1=new Cat("CodeCat")

          echo $cat1->meow();
        ?>

How Can I return a string in php functions?

Agostino
  • 1
  • 3

1 Answers1

1

You've missed word "function":

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

and ;

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

You should learn PHP more attentively

MrSmile
  • 1,217
  • 2
  • 12
  • 20