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

Objects in PHP Forum

View Course » View Exercise

307 points
55beeddd937676b2de000046_535113983
Submitted by
Sumanth
almost 2 years ago

(6/10) HELP

below is my code
the results tab says unexpected }
please tell me what is wrong

<!DOCTYPE html>


Reconstructing the Person Class




<?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("Sumanth", "Maddirala", 20);
    echo $student->age;

    echo $teacher->greet();
    echo $student->greet();



    ?>
  </p>
</body>

0 votes

permalink

on line 25 you have to erase the } and is ok after

592 points
1256a9dc94235a74aa842d94f1b5529f?s=140&d=retro
Submitted by
moriokaha
almost 2 years ago


0 votes

permalink

You missed semicolon ';' in the greet() function

686 points
9a60e17395e12f0b1698491eb02d15fa?s=140&d=retro
Submitted by
assenov
almost 2 years ago


0 votes

permalink

oh great, this solved my problem too
same error same solution
thanks

855 points
551918b895e37844e9005877_541826802
Submitted by
Ronshaan Hamesha
almost 2 years ago