Error Handling with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Error Handling with PHP

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post 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 :)
Post Reply