Trapping Error's

Hopefully someone can help here.
I have various SC app’s running in production that work 99% of the time. However every so often we get a reports that the app has thrown an error. I have tried a dozen different things to try and recreate error but without success.

Some simple code I found is shown below, but I cant seem to get it to work. I have searched all over for an asnwer but no joy.
function xhandler($number,$string,$file,$line,$context) { //log to text file? //log to xml file? //store in database? //whatever you want to do! }
/* use this error for ALL (E_ALL) errors */ set_error_handler(‘xhandler’,E_ALL);

But where would I put it, so that

Thanks

Larry

Something like this: https://stackoverflow.com/questions/6217994/php-how-to-use-set-error-handler-to-properly-deal-with-all-errors-except-noti
using set_error_handler and/or set_exception_handler ?

Hi IT. I Yes but I get the same error ell the time. What am I doing wrong?
[TABLE=“class: scErrorTable, align: center, cellpadding: 0, cellspacing: 0”]
[TR]
[TD=“class: scErrorTitle, align: left”]Error[/TD]
[/TR]
[TR]
[TD=“class: scErrorMessage, align: center”]set_exception_handler() expects the argument (globalExceptionHandler) to be a valid callback[/TD]
[/TR]
[/TABLE]
[TABLE=“class: scErrorTable, align: center, cellpadding: 0, cellspacing: 0”]
[TR]
[TD=“class: scErrorTitle, align: left”]Error[/TD]
[/TR]
[TR]
[TD=“class: scErrorMessage, align: center”]set_error_handler() expects the argument (globalErrorHandler) to be a valid callback[/TD]
[/TR]
[/TABLE]