
|
View Full Version : help! Deciphering error reporting settings
focus_dRu 02-11-2005, 12:17 AM I'm getting really confused by something that seems like it should be easier.
I am going through the growing pains of running a new dedicated server (through iPower : Linux/Plesk). I post here because here I think I'll find the PHP gurus.
My biggest frustrations have been trying to develop on a system that is not set up the same, PHP-wise. What I so enjoyed was the way the server gave me errors that I could easily find and fix. I have wrestled with the php.ini settings and ini_set to try to duplicate the settings and have those treasured helps back. I get so confused. I think I have them on and then I get a white screen when I encounter errors. Sometimes I get a 404 error in refreshing after a post (don't know if this is related). I don't know if it a combination of settings or settings I'm still clueless about.
trying to distinguish between
-- error_reporting (E_ALL)
and
-- ini_set("error_handling","E_ALL")
or is it
-- ini_set("error_handling","E_ALL")
Then there's
-- ini_set("display_errors","1")
or is it
-- ini_set("display_errors",1)
but maybe I could just fix it in the php.ini...
the errors I need to display are functional, programmatic errors.
I'd also like to know how to ignore undefined variable errors
(btw, I know about phpinfo(), just going (gone) crazy staring at it...)
Any help from your gurus is greatly appreciated.
Dru
gogocode 02-11-2005, 12:31 AM error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
focus_dRu 02-11-2005, 01:06 AM Thanks for your response.
I dropped that in my code and it gave me EVERYTHING. Don't want that much. I'm getting confused with that tilde (~). Do the different things E_ALL and on down, do they include each other (overlap) or is the only one that includes the others E_ALL. Okay, reading about this bitwise stuff. This is OVER my head at the moment. Hopefully it won't be soon. (I'm really a design guy, would you believe it? What am I doing with my own dedicated server??)
Can anyone help me with this bit construction?
dRu
gogocode 02-11-2005, 01:12 AM The error flags are intended to be modified using the bitwise operators. E_ALL includes everything.
If you don't want notices
E_ALL & ~E_NOTICE
if you don't want notices and warnings
E_ALL & ~(E_NOTICE | E_WARNING)
if you only want errors
E_ERROR
focus_dRu 02-11-2005, 01:18 AM Thanks, I'm getting ahold of it a bit. This is all new math for me. Thanks for taking a bit of time to help me.
Which one includes errors for undefined index? This one is a real pain.
gogocode 02-11-2005, 01:20 AM Originally posted by focus_dRu
Thanks, I'm getting ahold of it a bit. This is all new math for me. Thanks for taking a bit of time to help me.
Which one includes errors for undefined index? This one is a real pain.
Umm, not sure if they are notices or warnings. Probably warnings so
E_ALL & ~E_NOTICE should show them up.
error404 02-11-2005, 01:21 AM Basically, the parameter passed to error_reporting() is just an integer, but it's interpreted in a special way. As I'm sure you know, numbers in computers are represented by a series of bits. It's often useful to say things like 'if bit 7 is set, do this', and that's exactly what's happening here. E_ALL is simply an integer constant that has all (relevant) bits set to '1', enabling all error output. Each of the other constants available has a single bit set, that will be checked when that specific error type occurs, and if that bit is set, the error will be displayed.
Consider the case where you want both WARNINGs and COMPILE_ERRORs reported. The constants are E_WARNING (1) and E_COMPILE_ERROR (64).
Their binary values are:
E_WARNING = 000001
E_COMPILE_ERROR = 100000
E_WARNING | E_COMPILE_ERROR = 1000001 (65)
So what you need to do to is come up with the number that has both of those bits set, and the rest not set, and pass it to the error_reporting() function. There are two ways to do this, one is simply adding the two numbers together, but this is discouraged, as if you have the same bit set in the two numbers you're adding, you'll get unpredictable behaviour. The correct way to do it is to do a bitwise OR operation, which will return the binary number with bits set where there is a bit set in either the first operand OR the second operand. In PHP, this operator is '|', So, for this example:
error_reporting(E_WARNING | E_COMPILE_ERROR);
Of course, you probably won't want those ones, but check the PHP manual page (http://ca.php.net/error_reporting) to find out which you want. You can also negate a bit by performing an AND operation on the negation of that bit (E_ALL &~E_COMPILE_ERROR). The & operator sets only bits that are set in BOTH operands, and the ~ operator reverses the set bits (0001 becomes 1110).
focus_dRu 02-11-2005, 01:34 AM Thanks again. Man, this is driving me crazy. What would make my page not appear at all.
Back with iPower shared servers (oh yeah, back in Egypt...) it would give me nice parse errors (maybe that's what they were), would ignore the undefined errors. And they would always tell me the correct line to look at.
Looking back at a phpinfo() on that site, I see the error-reporting set at 2039.
Is that the same as
E_ALL & ~(E_NOTICE | E_ERROR)
?? Is the at right syntax?
thx again!!!
focus_dRu 02-11-2005, 01:37 AM That can't be it. Now I get a white page (blank). What would create that? It should catch parse errors, right? Like if I'm missing a ) or something.
focus_dRu 02-11-2005, 01:58 AM Still giving me a blank page after a post. Makes NO sense. I think I have the other figured out at
E_ALL & ~(E_NOTICE | E_ERROR)
actually references the correct line of code...
what's with the blank page, any guesses?
gogocode 02-12-2005, 05:53 AM Originally posted by focus_dRu
Still giving me a blank page after a post. Makes NO sense. I think I have the other figured out at
E_ALL & ~(E_NOTICE | E_ERROR)
actually references the correct line of code...
what's with the blank page, any guesses?
Could be anything. But first place I'd look is to see if php is segfaulting (crashing), check the apache logs for that.
|