|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-12-02 11:25 UTC] rueycheng at gmail dot com
[2004-12-13 03:09 UTC] iquito at gmx dot ch
[2005-01-12 02:03 UTC] tony2001@php.net
[2005-01-31 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 12:00:01 2025 UTC |
Description: ------------ Some filesystem functions, like file_put_contents() or fwrite(), don't work properly in the destructor __destruct(). The following scenario may looks a bit weird: it appeared that the file is not overwritten or even created, but PHP does 'read' the content of the imaginary file! If you uncomment the last line of the code, everything would works fine. Thanks. $ diff php.ini php.ini-dist 288c288 < error_reporting = E_ALL --- > error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT 436c436 < include_path = ".;c:\php-5.0.1\PEAR" --- > ;include_path = ".;c:\php\includes" 450c450 < extension_dir = "c:\php-5.0.1\ext" --- > extension_dir = "./" 571,573c571,573 < extension=php_mbstring.dll < extension=php_mcrypt.dll < extension=php_mhash.dll --- > ;extension=php_mbstring.dll > ;extension=php_mcrypt.dll > ;extension=php_mhash.dll 578c578 < extension=php_mysql.dll --- > ;extension=php_mysql.dll Reproduce code: --------------- <? class Bug { private $filename; public function __construct($filename) { $this->filename = $filename; } public function __destruct() { echo "["; file_put_contents($this->filename, 'Gotcha!'); echo file_get_contents($this->filename); echo "]"; } } $bug = new Bug('.bugtest'); //unset($bug); ?> Expected result: ---------------- [Gotcha!] (And the file .bugtest under working directory should be created.) $ cat .bugtest Gotcha! Actual result: -------------- [Gotcha!] $ cat .bugtest cat: .bugtest: No such file or directory