This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …
在您看来,使用@运算符来抑制PHP中的错误/警告是否有效,而您可能正在处理错误?
如果是这样,你会在什么情况下使用它?
欢迎使用代码示例.
编辑:回复者的注意事项.我不打算关闭错误报告,但是,例如,通常的做法是使用
@fopen($file);
Run Code Online (Sandbox Code Playgroud)
然后检查......但是你可以通过这样做摆脱@
if (file_exists($file))
{
fopen($file);
}
else
{
die('File not found');
}
Run Code Online (Sandbox Code Playgroud)
或类似的.
我想问题是 - 是否有任何@HAS用于抑制错误,不能以任何其他方式处理?