错误处理返回空白 [英] error handling returns blank
问题描述
我的代码中包含以下代码段:
开关($扩展名)
{
情况 gif:$ src = @imagecreatefromgif($ uploadedfile);打破;
case jpeg:$ src = @imagecreatefromjpeg($ uploadedfile);打破;
case png:$ src = @imagecreatefrompng($ uploadedfile);打破;
默认值:$ src = @imagecreatefromjpeg($ uploadedfile);打破;
}
if(!$ src)
die(错误:无法上传图片代码:#011);
脚本终止,但不返回错误。有人知道为什么吗?
如建议的那样,暂时删除@符号以找出哪个imagecreatefrom ...正在破坏您的脚本,一旦对其进行调试,便将它们放回原处。另外,因为您在imagecreatefrom ...函数之后回显了foo,该函数破坏了该过程,因此无论如何它永远不会打印出来。
评论后编辑:
好吧,如果您只想使用@来处理错误,那就行了, ll不显示该消息,但不显示发生致命错误的事实。您需要设置错误处理程序,并在此处中查找有关此信息。 p>
I have the following snippet from my code:
switch ($extention)
{
case "gif": $src = @imagecreatefromgif($uploadedfile); break;
case "jpeg": $src = @imagecreatefromjpeg($uploadedfile); break;
case "png": $src = @imagecreatefrompng($uploadedfile); break;
default: $src = @imagecreatefromjpeg($uploadedfile); break;
}
if(!$src)
die("Error: Could not upload image code:#011");
The script terminates but does not return error. Anyone know why?
As has been suggested temporarily remove the @ symbols to find out which imagecreatefrom... is breaking your script, once you've debugged it put them back in. Also because you've echoed foo after the imagecreatefrom... function that is breaking the process it'll never print out anyway.
EDIT AFTER COMMENTS:
Okay so if you want to handle the errors yourself just using @ won't work, it'll suppress the message but not the fact that a fatal error occurred. You'll need to set up an error handler, have a look here for information about this.
这篇关于错误处理返回空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!