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

Objects in PHP Forum

View Course » View Exercise

932 points
82cf462695a41a8a9ef78acf40d8b61c?s=140&d=retro
Submitted by
Catur Sura
over 2 years ago

Parse error: syntax error, unexpected T_PUBLIC, expecting T_STRING

Hi

i had some problem object in php

<!DOCTYPE html>
<html>
    <head>
      <title> Challenge Time! </title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
    </head>
    <body>
      <p>
        <?php
          // Your code here
          class Cat {
            public $isAlive = true;
            public $numLegs = 4;
            public $name;

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

            function public meow() {
                return "Meow meow";
            }
        }
        ?>
      </p>
    </body>
</html>

Parse error: syntax error, unexpected TPUBLIC, expecting TSTRING on line 16

Thanks in Advance


1 vote

permalink

oh my bad the code should use public function.

how stupid i am.

932 points
82cf462695a41a8a9ef78acf40d8b61c?s=140&d=retro
Submitted by
Catur Sura
over 2 years ago