note 38362 deleted from function.fopen by didou

From: Date: Tue, 30 Dec 2003 18:04:42 +0000
Subject: note 38362 deleted from function.fopen by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62690@lists.php.net to get a copy of this message
Note Submitter: orc ---- when attempting to reuse the same filename (eg: $txtfile = /home/username/public_html/php/textfile; ) such as a textfile in my case ; haven't tested for a binary, fclose fails despite fopen was successful.. scenario: reuse of $filename on two consecutive fopen/fclose sequences will bring up php crying about a file-handling error on the last fclose despite the second fopen being successful.. eg: The First time string filename used - $mbrFileNm = "/home/usernm/public_html/php/textfile"; $MBRFIL = fopen($mbrFileNm, "r"); if( $MBRFIL != false ){ while ( !feof($MBRFIL) ) { list( $username, $pw ) = split( " ", fgets($MBRFIL ,100)); $memlist_array[$username] = $pw; } fclose($MBRFIL); } - the second time its being used.. $FILEMF=fopen($mbrFileNm, "w"); if( $FILEMF != false ){ //this block enters successfully fputs($FILEMF, "test"); //test gets written, surprise! //blah blah procedures.. fclose($FILEMF); //php shoots out a 'warning' error, block still runs writting to file, but strangely it cries there's an invalid file handler to this variable.. } //// *** warning error given: --> it would say either a "3" or "4" on this error line jotted out... fclose(): 3 is not a valid stream resource in /phppath/file.php on line #<numberline of fclose> //// *** Php cries on the last fclose don't know why..the fix around is to use another name other than $mbrFileNm for the seond handle....Php needs much more work to become as competitve as Perl and Python..sorry but the PHP team should work harder...quite a shame, i'm going back to perl. Php, too many bugs..it sucks! -System tested on Apache 2.x + Php version 4.3.2 If you want filesystem functions, go perl..forget php its too "unstable".. orc

« previous php.notes (#62690) next »