PHPBuilder - File based, custom logging Page 3



RSS Twitter
Articles Site Operation

File based, custom logging - Page 3

by: John Starkey
|
September 30, 2002

Breaking the right rules

Ok, so we have our function ready to go for handling our logging calls. The next order of business is to tell the parser that it should use this function for handling any errors. To do this, we will use the set_error_handler() function as so:

<?php
set_error_handler
("simplisticLoggingFunction");
?>
Now, in order to see any results during this demonstration, we'll need to create our own error. To do this, I'll use a simple in_array() on a string variable. So, first we declare a variable with a string value:

<?php
$fake_array 
'test';
?>
Next, I will create an if statement which will throw an error by testing our faked array for the key 'Something':

<?php
if ( !in_array'Something'$fake_array ) ) 
{
    
trigger_error("Humph, you and I both know that wasn't an array"E_USER_NOTICE); 
    echo 
"An error has been posted to $log_file";
}
?>

« Previous Page
1
|
2
|
3
|
4
|
5
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
John Starkey

Comment:



Comment:

(Maximum characters: 1200). You have characters left.