当前位置:Gxlcms > PHP教程 > PHP文件操作类(创建文件并写入)生成日志_PHP教程

PHP文件操作类(创建文件并写入)生成日志_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

path = $path;
		}
		
		//判断操作方式 a追加写
		if (! empty ( $mode )) {
			$this->mode = $mode;
		}
		
		//判断写入的内容
		if (! empty ( $content )) {
			$this->content = $content;
		}
		
		$handle = fopen ( $this->path, $this->mode );
		
		//拆分换行
		$string = explode ( ",", $this->content );
		foreach ( $string as $v ) {
			fwrite ( $handle, $v . "\r\n" );
		}
		fclose ( $handle );
	}
}

//使用

$log = new log ();
// $log->addlog ();	//不传值 走默认值
// $log->addlog ( "./log", "a", " 内容1:$content1  内容2: $content2  内容3: $content3 " ); //传多个内容
// $log->addlog ( "./log", "a", "123,123,123" ); //一次插入并换行

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/780967.htmlTechArticlepath = $path;}//判断操作方式 a追加写if (! empty ( $mode )) {$this->mode = $mode;}//判断写入的内容if (! empty ( $content )) {$this->content = $content;}$handle = fop...

人气教程排行