public function system_log($logs) {
$log_name = 'log/log' . date('Y-m-d') . '.txt';//定义要创建文件的位置
$ch = fopen($log_name,'a+'); //打开文件,‘a+代表以读写的方式打开’
fwrite($ch,$logs . ' ' . date('Y-m-d H:i:s') . "\r\n");//写入文件
fclose($ch);//关闭文件
}
fopen(filename,mode,include_path,context)
参数 | 描述 |
---|
filename | 必需。规定要打开的文件或 URL。 |
mode | 必需。规定要求到该文件/流的访问类型。可能的值见下表。 |
include_path | 可选。如果也需要在 include_path 中检索文件的话,可以将该参数设为 1 或 TRUE。 |
context | 可选。规定文件句柄的环境。Context 是可以修改流的行为的一套选项。 |
fwrite(file,string,length)
参数 | 描述 |
---|
file | 必需。规定要写入的打开文件。 |
string | 必需。规定要写入文件的字符串。 |
length | 可选。规定要写入的最大字节数。 |
fclose(file)