Sitter och leker lite med PHP och objektorientering...
Har skapat en liten klass som följer:
class book {
private $ISBN;
private $author;
function getISBN() {
return $this->$ISBN;
}
function setISBN($ISBN){
$this->$ISBN = $ISBN;
}
function getAuthor(){
return $this->$author;
}
function setAuthor($author){
$this->$author = $author;
}
}
Sedan försöker jag använda den såhär:
include 'data.php';
$books = new book();
$books->setAuthor("johan");
$books->setISBN("1112");
echo $books->getAuthor();
Men då får jag följande fel meddelande:
PHP Notice: Undefined variable: author in /test/include/data.php on line 16
PHP Notice: Undefined property: book::$ in /test/include/data.php on line 16
Vad är detjag har tänkt fel?