daily pastebin goal
88%
SHARE
TWEET

Untitled

SashaRaaa Jul 17th, 2018 66 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top