note 129367 added to language.oop5.basic
| From: | cleverman@gmail.com | Date: | Sun, 31 Mar 2024 20:06:28 +0000 |
| Subject: | note 129367 added to language.oop5.basic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221267@lists.php.net to get a copy of this message | ||
<?php
class Book {
private $title;
private $author;
private $isbn;
private $available;
public function __construct($title, $author, $isbn) {
$this->title = $title;
$this->author = $author;
$this->isbn = $isbn;
$this->available = true;
}
public function borrow() {
if ($this->available) {
$this->available = false;
return true;
} else {
return false;
}
}
public function returnBook() {
$this->available = true;
}
public function getInfo() {
return "Naslov: {$this->title}, Autor: {$this->author}, ISBN:
{$this->isbn}";
}
}
$book1 = new Book("title", "author", "1990");
echo $book1->getInfo() . "<br>";
if ($book1->borrow()) {
echo "book is borrowed<br>";
} else {
echo "book isnt borrowed.<br>";
}
$book1->returnBook();
if ($book1->borrow()) {
echo "book is borrowed.<br>";
} else {
echo "book isnt borrowed.<br>";
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.131 (proxied: 188.252.187.124)
----
Manual Page -- https://php.net/manual/en/language.oop5.basic.php
Edit -- https://main.php.net/note/edit/129367
Del: integrated -- https://main.php.net/note/delete/129367/integrated
Del: useless -- https://main.php.net/note/delete/129367/useless
Del: bad code -- https://main.php.net/note/delete/129367/bad+code
Del: spam -- https://main.php.net/note/delete/129367/spam
Del: non-english -- https://main.php.net/note/delete/129367/non-english
Del: in docs -- https://main.php.net/note/delete/129367/in+docs
Del: other reasons-- https://main.php.net/note/delete/129367
Reject -- https://main.php.net/note/reject/129367
Search -- https://main.php.net/manage/user-notes.php