#36831 [Opn->Bgs]: Trying to create a file in destructor fails
| From: | helly@php.net | Date: | Thu, 23 Mar 2006 11:34:40 +0000 |
| Subject: | #36831 [Opn->Bgs]: Trying to create a file in destructor fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-94807@lists.php.net to get a copy of this message | ||
ID: 36831
Updated by: helly@php.net
Reported By: felho at avalon dot aut dot bme dot hu
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
-Operating System: Windows XP SP2
+Operating System: *
-PHP Version: 5.1.2
+PHP Version: *
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Most parts of php are already shutdown when the engine calls the
destructors after the script ends. For the same reason you cannot
output anything from a destructor.
Previous Comments:
------------------------------------------------------------------------
[2006-03-23 12:24:08] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36831&edit=1