<?php if(@$isLogin and $userinfo->role == "user"): ?>
what does @$isLogin mean here?
<?php if(@$isLogin and $userinfo->role == "user"): ?>
what does @$isLogin mean here?
@ is used to suppress error warnings, as far as I know. Prolly means it should be coded better.
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() .
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
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.
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.