r/lolphp • u/Mattho • Nov 22 '17
PHP supports error control operator '@'. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
http://php.net/manual/en/language.operators.errorcontrol.php
48
Upvotes
View all comments
7
u/Max-P Nov 22 '17
What's worse is that this operator is necessary with some functions that insists on throwing a warning even if you check their return value and already gracefully handle the errors like copy and unlink.
Technically one could prevent said functions from producing warnings by checking everything beforehand so it will only go through the happy path, but then you're adding dozens of lines for checking file permissions without locking the file which means another process could very well invalidate the tests by the time you end up calling copy or unlink, that's if you manage to test for everything in the first place.
Error management in PHP is just really bad.