Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class TextFile {
- protected $file;
- public function __construct ($file) {
- $this->file = fopen ( $file, 'a+' );
- while ( !feof($this->file) ) {
- $line = fgets($this->file, 1024);
- $this->reviews[] = $line;
- }
- }
- public function save() {
- fwrite ($this->file, $this->newreview);
- }
- }
- class GuestBook extends TextFile {
- protected $newreview;
- protected $reviews = [];
- public function getData() {
- return $this->reviews;
- }
- public function append($newreview) {
- $this->reviews[] = $newreview;
- $this->newreview = $newreview;
- }
- public function showbook() {
- foreach ($this->reviews as $review) {
- echo "\n" . $review;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement