我看到一些看起来像这样的代码:
if(@$_POST['myvar'])
Run Code Online (Sandbox Code Playgroud)
@符号在这个例子中做了什么?
它可以抑制打印任何警告/通知/错误.例如,如果$_POST['myvar']我们未定义,PHP可能会输出Undefined index通知.在@防止这种行为.
话虽如此,任意压制警告被认为是不好的做法.相反,您可以检查要设置的变量if (isset($_POST['myvar']) && $_POST['myvar'])
http://www.php.net/manual/en/language.operators.errorcontrol.php