-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathavarage_class.php
More file actions
36 lines (26 loc) · 927 Bytes
/
avarage_class.php
File metadata and controls
36 lines (26 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
class Comment {
private $author;
private $content;
private $timestamp;
public function __construct($author, $content) {
$this->author = $author;
$this->content = $content;
$this->timestamp = time();
}
public function getAuthor() {
return $this->author;
}
public function getContent() {
return $this->content;
}
public function getTimestamp() {
return $this->timestamp;
}
}
$comment1 = new Comment("John Doe", "This is a great article!");
$comment2 = new Comment("Jane Smith", "I enjoyed reading this.");
echo "Comment 1: " . $comment1->getContent() . " - by " . $comment1->getAuthor() . "<br>";
echo "Comment 2: " . $comment2->getContent() . " - by " . $comment2->getAuthor() . "<br>";
echo "Comment 1 timestamp: " . $comment1->getTimestamp() . "<br>";
echo "Comment 2 timestamp: " . $comment2->getTimestamp() . "<br>";