die()的PHP问题

时间:2010-05-21 19:56:52

标签: php die

所以,我有这段代码:

        } else {

            $photograph_moderation = new PhotographModeration($this->photograph_id);
            $photograph_moderation->purgePhotograph();

            //eventually take to an error page
            die('image is not big enough to upload');

        }

当满足此条件时,将正确调用purgePhotograph()函数,但脚本永远不会死亡。有没有理由为什么死不会在这里被称为? purgePhotograph()也没有脚本执行命令。

这是purge_photograph功能:

public function purgePhotograph() {

    $db = Connect::connect();
    $photograph_id = $db->real_escape_string($this->photograph_id);

    $query = "SELECT * from photographs WHERE id='{$this->photograph_id}'";
    $result = $db->query($query);
    $photograph = $result->fetch_assoc();

    if ($photograph['location'])
    unlink($photograph['location']);

    if ($photograph['thumbnail_location'])
    unlink($photograph['thumbnail_location']);

    if ($photograph['watermark_location'])
    unlink($photograph['watermark_location']);

    if ($photograph['xsmall_location'])
    unlink($photograph['xsmall_location']);

    if ($photograph['small_location'])
    unlink($photograph['small_location']);

    if ($photograph['medium_location'])
    unlink($photograph['medium_location']);

    if ($photograph['large_location'])
    unlink($photograph['large_location']);

    if ($photograph['xlarge_location'])
    unlink($photograph['xlarge_location']);

    if ($photograph['xxlarge_location'])
    unlink($photograph['xxlarge_location']);

    if ($photograph['xxxlarge_location'])
    unlink($photograph['xxxlarge_location']);

    $query = "DELETE from photographs WHERE id='{$this->photograph_id}'";
    $result = $db->query($query);

    $query = "DELETE from photograph_tags WHERE photograph_id='{$this->photograph_id}'";
    $result = $db->query($query);

}

4 个答案:

答案 0 :(得分:2)

检查purgePhotograph()是否返回。也许它有一个死循环或需要很长时间。

答案 1 :(得分:1)

也许现在是时候安装php debugger module并进入有问题的代码 xdebug例如netbeans因为前端工作得很好。

答案 2 :(得分:1)

哇,问题是purgePhotograph()从未有过返回1;在末尾。我不知道这是执行以下行所必需的。

答案 3 :(得分:0)

尝试将其放入try / catch块中。 也许有些事情会在死亡被执行之前抛出异常。

您收到任何错误吗?