destructor is called:
- for any object that you created
- in the part of the script that you posted, you did not initiate any object - perhaps the reason the destructor was not called?
- php script at the end
Using a header for redirection does not prevent the destructor from being called.
, PHP script - , , "", .
, :
class Test {
public function __destruct() {
echo 'hehe';
file_put_contents('/tmp/test-desctructor.txt', "glop\n");
exit;
}
}
$a = new Test();
header('Location: http://example.com/');
exit;
( , instanciation )
"hehe" , , /tmp/test-desctructor.txt:
$ cat /tmp/test-desctructor.txt
glop
, "hehe" .
, , , .
, manual ( - ):
. , script HTTP- .
"hehe" : ; ; -)
, btw;-)