SPASM

Untitled

Dec 10th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2.  
  3. class GuestBook
  4. {
  5.         public $path;
  6.         protected $data;
  7.  
  8.         public function __construct($path)
  9.         {
  10.             $this->path = $path;
  11.             $this->data = fopen($path, 'a');
  12.         }
  13.  
  14.         public function getData() {
  15.             return file($this->path, FILE_IGNORE_NEW_LINES);
  16.         }
  17.  
  18.         public function append($text) {
  19.             $array = $this->getData();
  20.             $array[] = $text;
  21.             return $array;
  22.         }
  23.  
  24.         public function save() {
  25.             file_put_contents($this->path, $this->append($text), FILE_APPEND);
  26.         }
  27.  
  28. }
Add Comment
Please, Sign In to add comment