Phison-up10 mass production tool v1.78.00 PHP writing text log implementation code

WBOY
Release: 2016-07-29 08:42:51
Original
1223 people have browsed it

Copy code The code is as follows:


**
* Write file
* @param string $file File path
* @param string $str Write content
* @param char $mode Write mode
* /
function writeFile($file,$str,$mode='w')
{
$oldmask = @umask(0);
$fp = @fopen($file,$mode);
@flock($fp , 3);
if(!$fp)
{
Return false;
}
else
{
@fwrite($fp,$str);
@fclose($fp);
@umask($oldmask);
Return true;
}
}


Extend the application, such as recording the URL content of each request

Copy the code The code is as follows:


function writeGetUrlInfo()
{
   //Get the address of the requester , client, requested page and parameters
  $requestInformation = $_SERVER['REMOTE_ADDR'].', '.$_SERVER['HTTP_USER_AGENT'].', http://'.$_SERVER['HTTP_HOST'].htmlentities ($_SERVER['PHP_SELF']).'?'.$_SERVER['QUERY_STRING']."n";
  $fileName = RootPath.'/log/'.date('Y-m-d').'.log '; //The website root directory RootPath is in the configuration file define('RootPath', substr(dirname(__FILE__)));
 writeFile($fileName, $requestInformation, 'a'); //Indicates appending
}


Use file_put_contents($filename,$data,FILE_APPEND); better

The above introduces the phison-up10 mass production tool v1.78.00 PHP text log implementation code, including the content of phison-up10 mass production tool v1.78.00. I hope it will be helpful to friends who are interested in PHP tutorials.

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template