Advertisement
SashaRaaa

Untitled

Jul 20th, 2018
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class TextFile {
  4.    
  5. protected $file;
  6.  
  7. public function __construct ($file) {
  8.    $this->file = fopen ( $file, 'a+' );
  9.    while ( !feof($this->file) ) {
  10.    $line = fgets($this->file, 1024);
  11.    $this->reviews[] = $line;
  12.  }
  13. }
  14.  
  15. public function save() {
  16.     fwrite ($this->file, $this->newreview);
  17.    }
  18.  
  19. }
  20.  
  21. class GuestBook extends TextFile {
  22.    
  23. protected $newreview;  
  24. protected $reviews = [];
  25.  
  26. public function getData() {
  27.    return $this->reviews;
  28. }
  29.  
  30. public function append($newreview) {
  31.    $this->reviews[] = $newreview;
  32.    $this->newreview = $newreview;
  33. }
  34.  
  35. public function showbook() {
  36. foreach ($this->reviews as $review) {
  37. echo "\n" . $review;
  38. }  
  39. }
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement