Advertisement
SashaRaaa

Untitled

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