开发者

Can this PHP Script be killed?

<?php

class Test {

    public function foo() {
        echo "Foo!";
        die();
    }

    public function __destruct() {
        header('location: http://google.com');
    }

}

$Test = new Test;
$Test->foo();

I have a class which simply assign's various Session variables then pings the user back to their previous script. I figured that it would be simpler to have a single redirect on 开发者_如何学Cthe destruct instead of 10 lines saying the same thing.

I later found a bug in my script and found out that it was nigh on unkillable. For future reference, is there anyway to kill this script or will it always redirect?

To clarify, the script always redirects even with die(), exit in the foo function.


$Test object is destructed when a browser disconnects: it won't redirect just because the browser won't receive the header! However, if you explicitly unset($Test);, it will

UPD: I'm wrong: the script will call all destructors with the browser still connected. However, I wouldn't rely on that

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜