Hi,

I have two classes 1) Person 2) Greeter I want to achieve followings how could i do that any help wih code example towards resolution of this is very much appreciated:-

1) Create an instance of class Person by passing a name to its constructor.
2) Create an instance of class Greeter by passing the Person instance from step 1 to its constructor.
3) Call the greetSubject() method on the Greeter instance from step 2.
4) The greetSubject() method uses the getName() method on its own $subject field.

***************
1) Person:-

<!DOCTYPE html>
<html>
<body>

<?php
class Person {
public $name;

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

function get_name() {
return $this->name;
}

}

$David = new Person("David");
echo $David->get_name();
echo "<br>";
?>

</body>
</html>
*********************************
2) Greeter:-
<!DOCTYPE html>
<html>
<body>

<?php
class Greeter {
public $subject;

function __construct($subject) {
$this->subject = $subject;
}
function get_subject() {
return $this->subject;
}
}

$science = new Greeter("science");
echo $science->get_subject();
?>

</body>
</html>
*******************************************

Thanks