|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-09-10 04:41 UTC] soletan at toxa dot 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: ...")
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 20 19:00:01 2025 UTC |
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 ...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 ...