I am updating the old code (someone wrote) and came across this:
if ( empty ( $role_data["role_id" == 1]))
what are the reasons (if any) should be used above, and not ?:
if ( $role_data["role_id"] != 1)
IMO readability is worse and this is more code. Performance is not a factor.
- EDIT -
It should be noted that the expected input ($ role_data ["role_id"]) is a number from 0 to 5 (inclusive)
- ADDITIONAL INFORMATION -
I missed the code for the first time. But here is what happens:
$role_id = htmlspecialchars ( mysql_real_escape_string ( $_GET["role_id"] ) ); $role_data = $db->fctSelectData ( "core_role" , "`role_id` = '" . $role_id . "'" );
This is done to obtain permissions to create the role. But if the invalid $role_id specified $role_id (via the $ _GET parameter), it does not return anything and, therefore, checks the empty value in:
if ( empty ( $role_data["role_id" == 1] ) )
I still do not quite understand why it is written like this.
source share