display_errors if variable

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
matt1234
Forum Commoner
Posts: 44
Joined: Wed Nov 26, 2008 9:43 pm

display_errors if variable

Post by matt1234 »

So what I'm trying to see if it's possible is having my php.ini file have display_errors off but to display them if a certain user is logged in. But then I guess, for instance, if session_start() isn't put into the file correctly, it won't even be able to tell if the person is logged in. Any suggestions, and is this even a possibility (besides putting code to show errors if the person is logged in into every page)?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: display_errors if variable

Post by jaoudestudios »

Try and use this...

Code: Select all

 
error_reporting(0);
 
Switch it on and off depending on the user.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: display_errors if variable

Post by kaisellgren »

Or use set_error_handler() to use your own error handler function. Then accordingly in that function either display errors or not.
aschlosberg
Forum Newbie
Posts: 24
Joined: Fri Jan 23, 2009 10:17 pm

Re: display_errors if variable

Post by aschlosberg »

The display_errors directive can be set at runtime:

Code: Select all

ini_set('display_errors', 'On');
Post Reply