我看到有人在抨击警告的前面加了一个at符号。看起来是这样的:
@trigger_error('This method is deprecated', E_USER_DEPRECATED);
同时也知道 @ 操作人员 will basically make any error messages go away . 所以看起来这些警告什么都没有,而且 indeed they cause no output
@
@trigger_error('No one ever sees this', E_USER_DEPRECATED); trigger_error('Visible deprecation warning', E_USER_DEPRECATED);
因此,考虑到( 1 2 , 3 , 4 , 5
更重要的是,我在谷歌还找不到任何解释。似乎与 Symfony's error handling this extensive discussion on that subject ,但到目前为止我还没有找到一个明确的答案。
引用 Symfony 4 PHPUnit Bridge documentation :
@trigger_error('Your deprecation message', E_USER_DEPRECATED); 如果没有@-silening操作符,用户将需要选择退出否决通知。默认情况下,消声会交换此行为,并允许用户在准备好处理这些行为时选择加入(通过添加自定义错误处理程序,如此网桥提供的错误处理程序)。如果没有静音,则折旧通知将显示在折旧报告的非静音部分。
@trigger_error('Your deprecation message', E_USER_DEPRECATED);
如果没有@-silening操作符,用户将需要选择退出否决通知。默认情况下,消声会交换此行为,并允许用户在准备好处理这些行为时选择加入(通过添加自定义错误处理程序,如此网桥提供的错误处理程序)。如果没有静音,则折旧通知将显示在折旧报告的非静音部分。
这可以归结为 the following example :
set_error_handler(function ($errno, $errstr) { var_dump($errstr); }, E_USER_DEPRECATED); @trigger_error('Will only be seen from a custom error handler', E_USER_DEPRECATED);