[英]What does @ do in this php?
// Get the image information and display the image:
if ($image = @getimagesize ("../uploads/$pid")) {
echo "<div align=\"center\"><img src=\"show_image.php?image=$pid&name=" . urlencode($row['image_name']) . "\" $image[3] alt=\"{$row['print_name']}\" /></div>\n";
} else {
echo "<div align=\"center\">No image available.</div>\n";
}
What does @ do in @getimagesize? @在@getimagesize中做什么?
It is an Error Control Operator , that will mask (prevent from being displayed) any error the getimagesize
function could generate. 它是一个错误控制运算符 ,它将屏蔽(防止显示)
getimagesize
函数可能生成的任何错误。
It it generally not considered a good practice to use it : it makes your code really harder to debug (if there is an error, you won't know about it) : 通常,使用它不是一个好习惯:它会使您的代码真正难以调试(如果有错误,您将不会知道) :
Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution.
当前,“ @”错误控制运算符前缀甚至将针对严重错误禁用错误报告,这些错误将终止脚本执行。 Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.
除其他外,这意味着如果您使用“ @”抑制某个功能的错误,并且该功能不可用或输入错误,该脚本将在那里死掉,而没有任何指示。
There is even a PHP extension, called scream , that disables this operator -- can be pretty useful when you are maintaintaing an apllication that used this operator a lot... 甚至还有一个名为scream的PHP扩展,它禁用了该运算符-当您维护一个经常使用该运算符的复本时,该功能非常有用...
Generally, it is better to set error_reporting
( see also ) level and display_errors
so that errors are displayed in development, and not in production -- that's way more useful that just always hiding them ! 通常,最好设置
error_reporting
( 请参见 )级别和display_errors
以便在开发而不是生产中显示错误-这比总是隐藏它们更有用!
它可以阻止从该特定函数调用中显示和/或记录错误。
It suppress errors to appear. 它抑制出现错误。 If the command you are invoking has an error or a warning to state, you will not get any printout in the page.
如果您正在调用的命令有错误或警告状态,您将不会在页面中得到任何打印输出。 You can also see it used with mysql_* routines.
您还可以看到它与mysql_ *例程一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.