Created
February 16, 2012 12:12
-
-
Save mipmip/1844419 to your computer and use it in GitHub Desktop.
Quick and dirty logging in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function log($msg) | |
{ | |
//using the date() function | |
$time = date("F jS Y, h:iA"); | |
//$remote_addr is PHP variable to get ip address | |
$ip = $REMOTE_ADDR; | |
//$http_referer is PHP variable to get referer | |
$referer = $HTTP_REFERER; | |
//$http_user_agent is PHP variable for browser | |
$browser = $HTTP_USER_AGENT; | |
//what page they came from | |
$page = $_SERVER['REQUEST_URI']; | |
//use the fopen() function | |
$fp = fopen("/tmp/jinn.log", "a"); | |
//using the fputs() function | |
fputs($fp, " | |
Time: $time | |
IP: $ip | |
Referer: $referer | |
Browser: $browser | |
Page: $page | |
Msg: $msg | |
"); | |
fclose($fp); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment