ameerulislam — 2013-09-28T01:36:15-04:00 — #1
<?php if(@$isLogin and $userinfo->role == "user"): ?>
what does @$isLogin mean here?
ralphm — 2013-09-28T01:48:42-04:00 — #2
@ is used to suppress error warnings, as far as I know. Prolly means it should be coded better.
spacephoenix — 2013-09-28T03:25:53-04:00 — #3
It's probably been placed there in-case the the $isLogin has not been "set". You can check to see if a variable is "set" using isset() .
hall_of_famer — 2013-09-28T04:30:35-04:00 — #4
to suppress warning messages, it is a bad programming practice but can be useful for legacy code, especially if it comes from third party that you have no idea or interest in refactoring/fixing. For me though, I run a VB3.8 forum that I end up using lots of @ operator to suppress warning messages generated due to PHP version compatibility. sigh
qmonkey — 2013-09-28T22:20:24-04:00 — #5
I've never seen it used to check a boolean like that. Better would be
if( isset( $isLogin ) && $isLogin )
Using error suppression increases overhead (slows the script a little) and makes it harder to debug. It can be useful sometimes but for cases like that, no way.
mittineague — 2013-09-29T03:51:25-04:00 — #6
I agree. Using error suppression is usually a sign of poor coding. Even if you can't use native functions it seems to me one could usually use some error/exception handling to log unexpected errors that might happen and are beyond your control.
I once submitted a ticket to WordPress listing all the places that I knew of where error suppression was used in the Core files, and even gave fixes for several.
Waste of time, too busy adding features and chasing down security bugs I guess.