Home > Article > Backend Development > PHP file operation class creates files and writes_PHP tutorial
if (! empty ( $mode )) {
$this->mode = $mode;
}
// Determine the written content
if (! empty ( $content )) {
$this->content = $content;
}
$handle = fopen ( $this->path, $this->mode );
// Split and wrap
$string = explode ( ",", $this->content );
foreach ( $string as $v ) {
fwrite ( $handle, $v . "rn" );
}
fclose ( $handle );
}
}
//Use
$log = new log ();
// $log->addlog (); //Do not pass a value and use the default value
// $log->addlog ( "./log", "a", " Content 1: $content1 Content 2: $content2 Content 3: $content3 " ); // Pass multiple contents
// $log->addlog ( "./log", "a", "123,123,123" ); //Insert and wrap once