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

Objects in PHP Forum

View Course » View Exercise

114 points
52d4f99e52f863f374000e81_769649322
Submitted by
Tobias Corompt
over 3 years ago

7/10 Parse error but I passed ó.Ò

It's strange. It let's me pass but it gives me this: Parse error: syntax error, unexpected ';', expecting T_FUNCTION on line 15

My code:

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

Could you please tell me what I have done wrong? :-)


5 votes

permalink

Correct Solution

<?php
    class Dog  {

        public $numLegs = 4;
        public $name;


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

            }
        }
    ?>

331 points
52e5288852f863bf230079a0_592455567
Submitted by
Zain Ali
over 3 years ago

2 Comments

52d4f99e52f863f374000e81_769649322 Tobias Corompt over 3 years ago

It's like you said :) I forgot the } at the end ^^ Thanks ;)

52e5288852f863bf230079a0_592455567 Zain Ali over 3 years ago

You're welcome. :)


0 votes

permalink

I had no problems with the code shown above as it's identical to mine, with which i got a full pass with no syntax errors, just accept it as correct.

566 points
52e29b20631fe9c2f0000276_260834778
Submitted by
Daniel Scarborough
over 3 years ago


0 votes

permalink

Thank you all for your help ;) my error is gone ;D

114 points
52d4f99e52f863f374000e81_769649322
Submitted by
Tobias Corompt
over 3 years ago


-2 votes

permalink

You did NOTHING!
I checked your code and is EXACTLY equal to my code. And i passed with no error.
This compiler sometimes is all fckd up xD

606 points
52e19cac282ae3eb240006ae_507370455
Submitted by
Francisco Kiko
over 3 years ago