Advertisement
SashaRaaa

Untitled

Jul 19th, 2018
752
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.    foreach ($this->reviews as $review) {
  27.    fwrite ($this->file, $review);
  28.    }
  29.    }
  30.  
  31. public function showbook() {
  32. foreach ($this->reviews as $review) {
  33. echo $review.'<br>';
  34. }  
  35. }
  36. }
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement