Valid use cases for at-sign in php

前端 未结 6 1388
天命终不由人
天命终不由人 2021-01-23 09:16

The at sign is used to hide error messages. As far as I see, there is absolutely no use case or excuse for using it.

  1. You can hide errors in production by changing
6条回答
  •  一向
    一向 (楼主)
    2021-01-23 09:38

    As with all tools available (both in programming and outside of it), everything has a legitimate use case.

    The first example that comes to mind for the error suppression operator would be something like

    if (!@unlink($file)) {
        // I am already handling the error. I don't care what caused it.
        // Even NOT handling this case at all could be a legitimate reaction
        // depending on circumstances.
    }
    

提交回复
热议问题