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

For Loops in PHP Forum

View Course

54 points
478038f2d2756db79fb2f01281d8c51f?s=140&d=retro
Submitted by
zigglr
over 1 year ago

Objects in php 6/10 error: Unexpected }

It keeps saying unexpected } on line 28
Here is my code:

<?php

    class Person {
     public $isAlive = true; 
     public $firstname;
     public $lastname;
     public $age;

    public function __construct($firstname, $lastname, $age) {
        $this->firstname = $firstname;
        $this->lastname = $lastname;
        $this->age = $age;
        }

    public function greet() {
     return "Hello, my name is " . $this->firstname . " " . 
     $this->lastname .". Nice to meet you! :)"    
    }
    }


    $teacher = new Person("boring", "12345", 12345);
    $student = new Person("Brad","de Padey", 19);
      ?>

0 votes

permalink

There is no semicolon at the end of your return statement.

1288 points
Cd63ccf5369069002b667d4ebf703ac5?s=140&d=retro
Submitted by
sksn
over 1 year ago