syslog() sends error messages to the system's central error tracking facility. The system's logging mechanism supports many features including e-mail notification.

<?php
// initialize syslog constants
define_syslog_variables();

/* open system log file.
 * The LOG_ODELAY indicated that that logging facility
 * should not be opened until an actual error occurs.
 */
openlog("PHP Error"LOG_ODELAYLOG_USER);

if (!
input_validation()) {
     
syslog(LOG_ALERT"H4x0r detected at {$_SERVER['REMOTE_ADDR']} {$_SERVER['HTTP_USER_AGENT']}");
}

closelog(); // close log
?>