|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-23 12:24 UTC] felho at avalon dot aut dot bme dot hu
Description:
------------
In case when an object is freed up at the end of the script file creation will fail in destructor. When I force this before the end of script the file will be created.
Reproduce code:
---------------
<?php
class foo {
function __construct()
{
fopen(date('YmdHim').'.const.txt', 'w');
mail('felho@x.hu', date('YmdHim').'.const.txt', '');
}
function __destruct()
{
fopen(date('YmdHim').'.dest.txt', 'w');
mail('felho@x.hu', date('YmdHim').'.dest.txt', '');
}
}
$foo = new foo();
//$foo = 1;
?>
Expected result:
----------------
Creating two files and sending two mails.
Actual result:
--------------
Only one file was created but two mails was sent. If you remove the comment on the last line, the second file was created too.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 13:00:01 2025 UTC |
"Most parts of php are already shutdown when the engine calls the destructors after the script ends." My first thought was to choose documentation related bug. This is not mentioned in the manual on the page which is related to __destruct. "For the same reason you cannot output anything from a destructor." It is funny, that the example in the manual exactly do this. function __destruct() { print "Destroying " . $this->name . "\n"; }