<?php/** * File operation (generate log) supports multiple inserts * (if multiple statements are inserted and line breaks with ', ' comma separated) * */class Log {public $path = './info.txt ';//default file public $mode = ' a ';//default Append write public $content = ' default value: null ';//default content is empty public function addlog ($path = null, $mode = NULL, $content = NULL) {//judgment Whether the file name being written is empty if (! empty ($path)) {$this->path = $path;} Determine how to add a write if (! empty ($mode)) {$this->mode = $mode;} Determine what to write if (! empty ($content)) {$this->content = $content;} $handle = fopen ($this->path, $this->mode);//split newline $string = Explode (",", $this->content); foreach ($string as $v) {fwrite ($handle, $v. "\ r \ n");} Fclose ($handle);}} Use $log = new log ();//$log->addlog ()/////$log->addlog ("./log", "a", "Content 1: $content 1 content 2: $content 2 Content 3: $content 3 "); Pass multiple content//$log->addlog ("./log", "a", "123,123,123"); Insert and wrap at once