PHP Classes

File: readme.txt

Recommend this page to a friend!
  Classes of Fabrizio Parrella   bib_errors   readme.txt   Download  
File: readme.txt
Role: Documentation
Content type: text/plain
Description: READ ME
Class: bib_errors
Log and process errors of PHP scripts
Author: By
Last change:
Date: 18 years ago
Size: 2,143 bytes


Class file image Download
to use the class, just include the file in your script. You can declare few variables or change the variables in the file: $_cfg['admin_email'] //this address will receive the email (default is the server_admin) $_cfg['code'] //a code that you assign to the website (default is the server_name) $_cfg['show_errors'] //if show the errors on the page or not (default from php.ini) $_cfg['log_errors'] //if you want or not log the errors (this will overwrite php.ini- default from php.ini) $_cfg['error_log'] //where the logfile is (this will overwrite php.ini - default from php.ini) $_cfg['email_errors'] //if you want to receive an email for each error you can also define a function that you want to user to log errors in a database or something else this function is called ONLY if log_errors = 1 leave it empty if you do not have any LOG functions. the class will be called passing some 3 parameters: - $error_text = text of the error - $type='notice' or 'warning' or 'error' in this case I pass a function that is in the $bibivu class, called 'write_log' previously declared. $f_error_log = array($bibivu,'write_log'); //$bibivu->write_log($test,$type); you can also pass a normal function, example, to call the function "write_log" that is not into a class: $f_error_log = 'write_log'; this is an example of configuration (that is also the default used in the class): if(!isset($_cfg['admin_email'])) $_cfg['admin_email'] = $_SERVER['SERVER_ADMIN']; //this address will receive a copy of the email if(!isset($_cfg['code'])) $_cfg['code'] = $_SERVER['SERVER_NAME']; if(!isset($_cfg['show_errors'])) $_cfg['show_errors'] = ini_get('display_errors'); //if show the errors on the page or not if(!isset($_cfg['log_errors'])) $_cfg['log_errors'] = ini_get('log_errors'); //if log the errors in a file or not if(!isset($_cfg['error_log'])) $_cfg['error_log'] = ini_get('error_log'); //file log //if(!isset($_cfg['error_log'])) $_cfg['error_log'] = $_SERVER['DOCUMENT_ROOT'].'/error.log'; //file log if(!isset($_cfg['email_errors'])) $_cfg['email_errors'] = '1';