#29167 [Opn]: fopen works differently in a constructor vs. a destructor

From: Date: Thu, 15 Jul 2004 07:12:47 +0000
Subject: #29167 [Opn]: fopen works differently in a constructor vs. a destructor
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-62340@lists.php.net to get a copy of this message
ID: 29167 Updated by: helly@php.net Reported By: kaspersv at privat dot dk Status: Open Bug Type: Filesystem function related -Operating System: Windows XP Professional +Operating System: * PHP Version: 5.0.0 New Comment: ATM you need to explicitly unset the object before script termination by using: unset($bugtest); Previous Comments: ------------------------------------------------------------------------ [2004-07-14 23:44:15] kaspersv at privat dot dk Description: ------------ When I run the attached code on my machine, it creates a file called testing.txt in the directory where the php-file was located, containing the line "Constructor". And another file in the apache servers root directory also called testing.txt, containing the line "Destructor". Reproduce code: --------------- <? class BugTest { function __construct() { $fp = fopen("testing.txt", "a"); fwrite($fp, "Constructor\n"); fclose($fp); } function __destruct() { $fp = fopen("testing.txt", "a"); fwrite($fp, "Destructor\n"); fclose($fp); } } $bugtest = new BugTest(); ?> Expected result: ---------------- A single file containing the two lines: Constructor Destructor ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29167&edit=1

« previous php.bugs (#62340) next »