|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-30 00:48 UTC] htmldoug at msn dot com
[2004-09-30 03:34 UTC] iliaa@php.net
[2004-10-08 01:01 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 01:00:02 2025 UTC |
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