PHP fopen() bug + solution

From: Date: Thu, 07 Nov 2002 23:51:53 +0000
Subject: PHP fopen() bug + solution
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-123282@lists.php.net to get a copy of this message
Hello, Bug: When creating a file using fopen() with an FTP URL, the file may not be completely written even after you call fflush() and ffclose(). If you try to include() or require() the file you've just created, it may not work properly even if there's no warning or error generated. Solution: After flushing and closing the file, (1) wait until the file exists, then (2) wait until the file is not empty. Example: while(!file_exists("index.php") { clearstatcache(); } while(filesize("index.php" < 10) { clearstatcache(); } All of this is related to the workaround of not being able to create local files as another use with PHP. I hope this saves someone a few hours, -- Charles Wiltgen

« previous php.general (#123282) next »