Page 1 of 1

Error Handling with PHP

Posted: Wed Nov 01, 2006 2:39 pm
by MrPotatoes
i need to be able to do two things and i'm getting a little stuck here.

first i'm trying to catch the error that PHP is throwing in global space. i want to catch that, find what the error is and then use my functions to handle that error gracefully instead of breaking out of the application completley.

secondly i wanted to be able to set error handling per users/admins. depending on the permissions set.

ok, the first i have no idea how to do. maybe

Code: Select all

ini_get("error_reporting");
the first thing that i'm doing is setting up an array of error values.

Code: Select all

$levels = array(
		E_ERROR				=>	'Error',
		E_WARNING			=>	'Warning',
		E_PARSE				=>	'Parsing Error',
		E_NOTICE			=>	'Notice',
		E_CORE_ERROR		=>	'Core Error',
		E_CORE_WARNING		=>	'Core Warning',
		E_COMPILE_ERROR		=>	'Compile Error',
		E_COMPILE_WARNING	=>	'Compile Warning',
		E_USER_ERROR		=>	'User Error',
		E_USER_WARNING		=>	'User Warning',
		E_USER_NOTICE		=>	'User Notice',
		E_STRICT			=>	'Runtime Notice'
);
then i wanted to catch that in global space. does anyone know how to do this?

thanks for your help :D

Posted: Wed Nov 01, 2006 2:47 pm
by feyd
set_error_handler()..

However, php code is only able to catch certain errors. Parse errors happen before the script begins execution, for instance.

Posted: Wed Nov 01, 2006 2:55 pm
by MrPotatoes
hee hee. i figured it out just now. i was here to edit it to say solved.

i'm going to fix this now and learn more about that. i'm not used to that "niceness" in PHP sometimes. i thought i had to do alot more work than i needed lmao.

thank you. i'll edit this bad boy now :)