错误处理返回空白 [英] error handeling returns blank

查看:218
本文介绍了错误处理返回空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  switch($ extention)
{
casegif:$ src = @imagecreatefromgif($ uploadedfile);打破;
casejpeg:$ src = @imagecreatefromjpeg($ uploadedfile);打破;
casepng:$ src = @imagecreatefrompng($ uploadedfile);打破;
default:$ src = @imagecreatefromjpeg($ uploadedfile);打破;
}

如果(!$ src)
死(错误:无法上传图像代码:#011);

脚本终止,但不返回错误。任何人都知道为什么?

解决方案

如建议临时删除@符号,找出哪个imagecreatefrom ...正在打破你的脚本一旦你调试了它,就把它们重新放入。另外,因为你在创建imagecreatefrom ...功能之后回覆了foo,所以打破这个过程,它永远都不会打印出来。



评论后编辑:



好的,如果你想自己处理错误,只是使用@不行,将抑制消息,但不会发生致命错误。您需要设置错误处理程序,请查看此处以获取有关的信息。 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆