Advertisement
SashaRaaa

Untitled

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