Skip to content

Instantly share code, notes, and snippets.

@roine
Created December 5, 2012 06:44
Show Gist options
  • Save roine/4213119 to your computer and use it in GitHub Desktop.
Save roine/4213119 to your computer and use it in GitHub Desktop.
howto
class Author {
private $firstName;
private $lastName;
public function __construct($firstName, $lastName) {
$this->firstName = $firstName;
$this->lastName = $lastName;
}
public function getFirstName() {
return $this->firstName;
}
public function getLastName() {
return $this->lastName;
}
}
class Question {
private $author;
private $question;
public function __construct($question, Author $author) {
$this->author = $author;
$this->question = $question;
}
public function getAuthor() {
return $this->author;
}
public function getQuestion() {
return $this->question;
}
}
$a = new Author('jon', 'dem');
$q = new Question(1212, $a);
echo $q->getAuthor()->getFirstName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment