3 ms·
Some negative comments about the @-operator seem to be very religious. It's just a tool that one can use for good or for evil. Many of the reasons not to use @
by artemgoutsoul 14y ago
Some negative comments about the @-operator seem to be very religious. It's just a tool that one can use for good or for evil. Many of the reasons not to use @ described are valid, but there are cases when it makes much cleaner code. E.g. instead of doing:
if (array_key_exists($key, $a) && $a[$key] == $value) dostuff();
you can do:
if (@$a[$key] == $value) dostuff();
This works really well when you don't care whether $a[$key]is present or not, and when you care only whether it contains a certain $value. In complex comparisons the code readability difference is huge!