http://php.net/manual/en/language.variables.php
<?php
/**
* An example class with member variables
* http://www.phpdoc.org/
*/
class Book {
public $author;
private $title;
protected $isbn;
/**
* @param String author , Example "J.K. Rowling"
* @param String title , Example "Harry Potter and the Philosopher's Stone"
* @param String isbn , Example "9788478888566"
*/
public function __construct($author, $title, $isbn) {
$this->author = $author;
$this->title = $title;
$this->isbn = $isbn;
}
/**
* @param Book other book to compare to
* @return boolean return true if the books are the same
*/
public function isSame(Book $other) {
if($this->author != $other->author) {
return false;
}
if($this->title != $other->title) {
return false;
}
if($this->isbn != $other->isbn) {
return false;
}
return true;
}
}
//Testcase
$book = new Book("Daniel", "PHP unlimited", "123456");
$bookSame = new Book("Daniel", "PHP unlimited", "123456");
$bookOther = new Book("Daniel", "PHP unlimited 2", "123457");
assert($book->isSame($bookSame) == true);
assert($book->isSame($bookOther) == false);