Home  >  Article  >  Backend Development  >  Simple log writing function implemented in php_PHP tutorial

Simple log writing function implemented in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:58:37974browse

Simple log writing function implemented in php

This article describes the simple log writing function implemented in php. Share it with everyone for your reference. The specific implementation method is as follows:

1

2

3

4

5

6

7

8

9

function log( $logthis ){

file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis. "rn", FILE_APPEND | LOCK_EX);

}

// use rn for new line on windows, just n on linux

// PHP_EOL cross platform solution for new line

// // so better to use this

function log( $logthis ){

file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis.PHP_EOL, FILE_APPEND | LOCK_EX);

}

1 2 3

4

6 7 8 9
function log( $logthis ){ file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis. "rn", FILE_APPEND | LOCK_EX);
}
// use rn for new line on windows, just n on linux // PHP_EOL cross platform solution for new line // // so better to use this function log( $logthis ){ file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis.PHP_EOL, FILE_APPEND | LOCK_EX); }
http://www.bkjia.com/PHPjc/977160.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/977160.htmlTechArticleSimple log writing function implemented in php. This article describes the simple log writing function implemented in php. Share it with everyone for your reference. The specific implementation method is as follows: 1 2 3 4 5 6 7 8 9 func...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn