ID: 30267
Comment by: htmldoug at msn dot com
Reported By: eiriksletteberg at hotmail dot com
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Windows 98SE
PHP Version: 5.0.1
New Comment:
Reproduction code run using PHP 5.0.2 under WinXP executes exactly as
expected.
Previous Comments:
------------------------------------------------------------------------
[2004-09-28 21:31:16] eiriksletteberg at hotmail dot com
Description:
------------
When this code is executed, one would expect data.txt
to contain "Hello World!". And, as file_get_contents() says,
it is. But when the script is completely executed, data.txt
does not contain "Hello World!" as it should. The
error does not occur if the destructor is called before
the script ends, eg. by unset()'ing $foo. Seems
like the destructor cannot write to files when called
at the end of scripts?!?
Reproduce code:
---------------
<?php
class data
{
function __destruct()
{
$data = "Hello World!";
// Show that the destructor is called
print "Destructor called.";
$link = fopen("data.txt", 'w');
fwrite($link, $data);
fclose($link);
// Check if we have written it
print "Contents: ".file_get_contents("data.txt");
}
}
$foo = new data;
?>
Expected result:
----------------
data.txt should contain "Hello World!"
Actual result:
--------------
data.txt is empty or contains the previous value
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30267&edit=1