views:

36

answers:

2

Is there a way to specify in php.ini or apache level that the script execution should halt on any warnings? I tried searching through google and stackoverflow but couldn't find any relevant information yet. I do know about the set_error_handler() function but I am looking to do this at the php.ini level.

A: 

AKAIK, there is no way to do something like that at the configuration level. However, I think it could be done using PHP's set_error_handler function.

http://php.net/manual/en/function.set-error-handler.php

Within the function you set, can detect a warning via the ERROR_TYPE parameter, and halt the script using exit or die.

Chris Henry
please read the question properly. i have already added that I know about the set_error_handler function but need a setting on the php.ini level. Thanks for the answer anyway.
pinaki
Please read the answer, and the other answer: There is no way to do what you are asking for. The answer attempted to provide the behaviour you're looking for, if not by the means you wanted.
Chris Henry
+1  A: 

So like always it's a little difficult to prove a negative like you're asking. About 14 seconds of googling yields the complete list of php.ini directives:

http://www.php.net/manual/en/ini.list.php

There are only 4 instances of the word 'warning' on this page, so it looks like that exotic idea is not an option.

umassthrower
while i do not agree to the method of your search (halting can well be under a more general category and not with the word 'warning'), i do agree that this is an exotic idea :-).. just wanted to make sure that the warning messages on a production server could never affect my script execution... thanks.
pinaki
I suppose you're right and if I was launching a space shuttle I would have put a little more effort into making sure there did not exist other directives that perhaps caused this behavior when toggled and were disguised as something innocent. :-)Just wanted to suggest to you the place I would look and give an example of how I would look for it. Like I said, difficult to prove the negative without testing or looking at code. You could also grep php.ini because, especially in 5.3 there are a ton of comments and if what you're looking for exists its comment might contain warning or hault.
umassthrower