[PHP] Re: suppressing errors with @
Doesn't surpress output (in general)? Variables don't usually produce an output so putting before it shouldn't make any difference. suppresses *ERROR* output, not just any old output. echo foo; will echo foo out. echo $foo; will echo out anything in $foo, but if you haven't *PUT* anything in $foo yet, and if you have E_ALL turned on like you should, then the will suppress the Warning: message. can generally appear just about anywhere, and not necessarily just in front of functions (unless this changed on purpose in 4.2 for some reason beyond my ken) I don't use a whole lot, except for pg_fetch_row() where you pretty much have to (ugh!) Anyway, this is legal (or was before 4.2), if silly: if ($foo){ } Here, the test for $foo, which might not be set, will suppress the Warning: about $foo not being set, because there is an in front of it. Of course, you *OUGHT* to be using: if (isset($foo)){ } in the first place! I dunno why the behaviour changed in the original post's case. Might even be an actual bug... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: suppressing errors with @
I use it in front of variables (never tried it on $GLOBALS, etc though) eg: (using register_globals = on thingo - hey don't blame me, it's the tech guys who have it on, and there's too much legacy code to turn it off :( - anyway) ? if ($var) { echo Yep, var is there; } else { echo nope; } ? The risk is in hackers using an un-initialized $var to pass in their own data. If you've *correctly* programmed and caught *every* single case where that might happen, by using isset() or even something like the above, only doing something more useful, you're almost-for-sure okay. register_globals off just annoys me since I *always* initialize variables, and there's no point to me re-writing the tons of scripts for it, but that's life. That said, the sheer number of non-programmers writing PHP made register_globals on a Bad Idea (tm) really... I guess even some good programmers could occasionally miss a variable initialization, though I never do :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: suppressing errors with @
Doesn't @ surpress output (in general)? Variables don't usually produce an output so putting @ before it shouldn't make any difference. Uri Even-Chen [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I tried to suppress warnings in isset expressions (Uninitialized string offset warnings). The original line was something like this: if (!(isset($GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) When I added the @ sign like this: if (!(isset(@$GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) My program stopped working, and I got errors like: PHP Parse error: parse error, expecting `T_VARIABLE' or `'$'' Eventually, I put the @ in this place: if (!(@isset($GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) Which works, but why didn't it work the other way? Is it some kind of PHP bug? I'm using PHP Version 4.1.2 Thanks, Uri. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: suppressing errors with @
I use it in front of variables (never tried it on $GLOBALS, etc though) eg: (using register_globals = on thingo - hey don't blame me, it's the tech guys who have it on, and there's too much legacy code to turn it off :( - anyway) ? if (@$var) { echo Yep, var is there; } else { echo nope; } ? -Original Message- From: Scott Fletcher [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 06, 2002 7:32 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: suppressing errors with @ No, it's not a PHP bug. The @ can not be used before a PHP variables, or PHP pre-defined variables like $GLOBALS, $_SESSION, $_GET, $HTTP_POST_VARS, etc. The @ is used only before the PHP function as far as I know of. FletchSOD Uri Even-Chen [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I tried to suppress warnings in isset expressions (Uninitialized string offset warnings). The original line was something like this: if (!(isset($GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) When I added the @ sign like this: if (!(isset(@$GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) My program stopped working, and I got errors like: PHP Parse error: parse error, expecting `T_VARIABLE' or `'$'' Eventually, I put the @ in this place: if (!(@isset($GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) Which works, but why didn't it work the other way? Is it some kind of PHP bug? I'm using PHP Version 4.1.2 Thanks, Uri. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: suppressing errors with @
No, it's not a PHP bug. The @ can not be used before a PHP variables, or PHP pre-defined variables like $GLOBALS, $_SESSION, $_GET, $HTTP_POST_VARS, etc. The @ is used only before the PHP function as far as I know of. FletchSOD Uri Even-Chen [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I tried to suppress warnings in isset expressions (Uninitialized string offset warnings). The original line was something like this: if (!(isset($GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) When I added the @ sign like this: if (!(isset(@$GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) My program stopped working, and I got errors like: PHP Parse error: parse error, expecting `T_VARIABLE' or `'$'' Eventually, I put the @ in this place: if (!(@isset($GLOBALS['SPEEDY_GLOBAL_VARS']['PAGE_NAME']))) Which works, but why didn't it work the other way? Is it some kind of PHP bug? I'm using PHP Version 4.1.2 Thanks, Uri. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php