#19329 [Opn->Bgs]: suppressing error messsages with '@' fails
| From: | mfischer@php.net | Date: | Wed, 11 Sep 2002 11:07:04 +0000 |
| Subject: | #19329 [Opn->Bgs]: suppressing error messsages with '@' fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-19029@lists.php.net to get a copy of this message | ||
ID: 19329
Updated by: mfischer@php.net
Reported By: soletan@toxa.de
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux 2.4.18
PHP Version: 4.2.3
New Comment:
Read the manual at
http://www.php.net/manual/en/function.set-error-handler.php
, this is
the expected behaviour.
Previous Comments:
------------------------------------------------------------------------
[2002-09-11 05:59:18] soletan@toxa.de
Well, here you get one ... but this way I found out, that this "bug"
might not be one of your concern. Maybe it's more about error reporting
or the scripting engine in general ... I can't decide as I don't know
that much about the internals of PHP.
----------------------------
<?php
set_error_handler( "draw_error" );
function draw_error( $numeric, $string ) {
die( "code: $numeric<BR>message: $string" );
}
if ( $handle = @fopen( "test.php5", "r" ) )
include( "test.php5" );
if ( $handle )
fclose( $handle );
?>
----------------------------
This way my error handler gets called even if @-operator supresses
error reporting ...
------------------------------------------------------------------------
[2002-09-10 19:44:47] sniper@php.net
Can you please provide a short, self-contained and ready to
copy+paste+run one instead of some snippet of code..?
------------------------------------------------------------------------
[2002-09-10 18:07:59] soletan@toxa.de
Some script example ...
------------------
// if ( ( @in_array( "DOM", $b["type"] ) ) && file_exists(
"../lib/ua-dep/layout-draw-css.php4" ) )
if ( ( @in_array( "DOM", $b["type"] ) ) && ( $handle = @fopen(
"../lib/ua-dep/layout-draw-css.php4", "r" ) ) )
include( "../lib/ua-dep/layout-draw-css.php4" );
// else if ( file_exists( "../lib/ua-dep/layout-draw-tables.php4" ) )
else if ( ( $handle = @fopen( "../lib/ua-dep/layout-draw-tables.php4",
"r" ) ) )
include( "../lib/ua-dep/layout-draw-tables.php4" );
else
...
------------------
I use this branching to serve the same content in different ways
depending on the client's browser. It works great for the second
uncommented "if", as soon as I comment out the first one. Without that
I have to place some script in given directory with correct name to
prevent the error message. Well, but apparently I want the snippet to
auto-detect, which module fits best and which is available currently.
This feature isn't possible. BTW: The second included script exists of
course, the first doesn't ...
------------------------------------------------------------------------
[2002-09-10 09:54:18] sniper@php.net
Please provide a short example script..
------------------------------------------------------------------------
[2002-09-10 04:41:29] soletan@toxa.de
Hi,
is it right to use '@' before function calls to prevent them from
producing error messages???
I'm using Apache 2.0.40 with PHP 4.2.3 and Zend Optimizer 2.0
included.
Well, I use it before fopen and get some message, that the file I'm
looking for isn't available for reading. After some stress with
file_exists I used this to workaround file_exists.
To test that problem I prepared to use 4.3.0-dev snapshot 200209082100
which I used now to test this new failure, again. It reports some error
message, too. It is just reformed to say the same with other words.
("failed to create stream: ...")
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19329&edit=1