Valid use cases for at-sign in php

前端 未结 6 1390
天命终不由人
天命终不由人 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

    The most common place I have seen it used is for suppressing mysql errors when working with a db. Then the user checks the response instead and prints an appropriate error message.

    Example

    
    

    I have also seen it used when working with ftps and sftps.

    But I agree with you that I find its uses limited. If one ends up in a situation where one feels the need to use the @-sign at own produced code, I think it's time to rethink the solution.

提交回复
热议问题