| classErrorLog.php |
|---|
• Overview:
The purpose of this class is to collect error messages and other notices so that all may be displayed at once in an orderly manner at some desired location on a web page. As discussed in the main documentation section, a switch should be set so that messages display only during testing, not in visitors' browsers.
The following steps illustrate instantiation and use of the class:
• Invocation:
• Set catastrophic error message:
• Set non-critical message:
• Display list of all messages:
• Complete source listing of classErrorLog.php:
<?
/*
filename: classErrorLog.php
author: Al Olmstead, AlOlmstead.com, Al@AlOlmstead.com
dependencies: none
*/
class ErrorLog {
var $errorLogArray;
function setErrorMsg($errorMsg) {
$errorLogArrayCount=count($this->errorLogArray);
$this->errorLogArray[$errorLogArrayCount]=
trim($errorMsg);
} // setErrorMsg()
function dumpErrorLog() {
$returnLine="";
$errorLogArrayCount=count($this->errorLogArray);
if($errorLogArrayCount>0) {
$returnLine='<h5 style="margin: 0; padding: 0; '.
'text-align: left;">Notices:</h5>';
for($x=0; $x<$errorLogArrayCount; $x++) {
$returnLine.='<p style="margin: 0; padding: 0; '.
'margin-left: 10px; margin-right: 2px;'.
'font-size: x-small; text-align: justify; '.
'text-indent: -10px;">'.
$this->errorLogArray[$x]."</p>";
} // for()
} // if()
return($returnLine);
} // dumpErrorLog()
function fileNotFound($fileName) {
$errorMsg='File "'.$fileName.
'" cannot be found. This problem prevents this '.
'website from functioning correctly. Please '.
'notify the Webmaster.';
$this->setErrorMsg($errorMsg);
} // fileNotFound()
function __construct() {
$this->errorLogArray=array();
} // __construct()
} // class ErrorLog{}
?>