Temporarily changing error_reporting()...doesn't seem to work 
Author Message
 Temporarily changing error_reporting()...doesn't seem to work

I would like to set error_reporting off when including some library code
and then set it back to it's previous value so I can fully debug my
code.  The following turns off  Notice reporting as expected.

Eliminates output as expected:  
$errorLevel = error_reporting();    // save initial error_reporting state
error_reporting(0);                        // set all error reporting off
require("oohforms.inc");                // include the library where I
normally get a lot of Notice reports

I would expect this to eliminate output during the include file but it
doesn't.  It restores output even during the include file...

$errorLevel = error_reporting();    // save initial error_reporting state
error_reporting(0);                        // set all error reporting off
require("oohforms.inc");                // include the library where I
normally get a lot of Notice reports
error_reporting($errorLevel);        // restore error_reporting to it's
previous value

Ideas?  Thanks, Rob



Wed, 17 Aug 2005 10:06:38 GMT  
 Temporarily changing error_reporting()...doesn't seem to work

Quote:

> I would expect this to eliminate output during the include file but
> it doesn't.  It restores output even during the include file...

I don't think it is restoring error reporting during the included
file, the included file most likely has its own calls to
error_reporting() which are overriding your previous calls. (I did
some tests to verify this.)

It does not seem like it's possible to override any error_reporting()
calls which the library may contain. A workaround is to turn off
display_errors, see
<http://www.php.net/manual/en/ref.errorfunc.php#ini.display-errors>.
You may even find more likeable workarounds by inspecting other ini
settings there.


suppresses errors of the actual inclusion, i.e., trying to include a
non-existent file, and not all errors throughout the included file.)

Quote:
> $errorLevel = error_reporting();    // save initial error_reporting state
> error_reporting(0);                        // set all error reporting off
> require("oohforms.inc");                // include the library where I
> normally get a lot of Notice reports
> error_reporting($errorLevel);        // restore error_reporting to
> it's previous value

It isn't necessary to make three calls to error_reporting(). When you
call error_reporting() it returns the *old* value, so you can replace
that with the more compact:

$old = error_reporting(0);
require('oohforms.inc');
error_reporting($old);

Also, there's no need to comment the obvious. I don't know whether or
not you just did that for the post, but even then, they were
unnecessary. If someone doesn't know what those functions do, they
should consult the manual. Such an extreme level of verbosity hinders
readability.

HTH,
--
steven vasilogianis



Wed, 17 Aug 2005 11:25:09 GMT  
 Temporarily changing error_reporting()...doesn't seem to work
Steven,  

Thanks for the input.  You gave me cause to see what was actually
happening.  In fact, error_reporting was working.  However, when I
called library functions later in the program AFTER I'd re-enabled
Notice reporting, I saw lots of Notice output...it "looked" the same to
me but of course was not.  It seems the entire library is written
without regard to notice reporting.  

That leaves the question of how to disable Notice reporting within the
library...seems like the easiest thing to do is fix it or use a
different forms class lib.  

Thanks also for the tips on clarity.  Rob



Wed, 17 Aug 2005 12:09:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. expect's full_buffer doesn't seem to work

2. set VIDEO_MODE_RESTRICTION=CGA doesn't seem to work

3. ios.gets doesn't seem to work as advertised

4. setting LD_LIBRARY_PATH doesn't seem to work?

5. proc doesn't seem to work in NASM

6. Micro Focus CALL-CONVENTION 8 doesn't seem to work

7. Adagide install doesn't seem to work?

8. problem with exec: import doesn't seem to work

9. ldap.modify_s doesn't seem to work

10. update doesn't seem to work with scale

11. BLT installs but doesn't work, and TkTable doesn't build

12. require doesn't seem to search $: on Win2K

 

 
Powered by phpBB® Forum Software