Skip navigation.

Harold's Home

   Home
  
XML version of this site

PHP Scripts

Index
CLI fun
Mail on 404
HB-NS (NewsScript)

Downloads

Applescripts
APOD to Desktop
Dreamweaver Extensions

Stuff

Writings
Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Bananas
Strippers
Sample Movies

News

Logging errors with PHP
I thought I had written about this earlier but I can't find it so perhaps I've only thought about it at some time.
Anyway, it can be quite useful to log some info to the apache error log when a PHP script is accessed.

Here's an example of how to do this using the error_log function:
<?php
$HTTP_REFERER = $_SERVER['HTTP_REFERER'];
if ($HTTP_REFERER == "") $HTTP_REFERER = "unknown";
$REQUEST_URI = $_SERVER['REQUEST_URI'];
error_log("NOTE: $REQUEST_URI accessed, referer: $HTTP_REFERER");
?>


This will print something like:
[Sun Jan 2 15:13:20 2005] [error] NOTE: /stuff/file.php accessed, referer: http://domain.com/file.html

Show all items | Read all items

About, copyright, privacy and accessibility | Mail