note 91008 added to function.file-exists

From: Date: Wed, 20 May 2009 20:39:48 +0000
Subject: note 91008 added to function.file-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-155807@lists.php.net to get a copy of this message
I want to warn developers using PHP 5.0.4 of a bug that don't happen in current stable versions: file_exists seems to cache the response, even when the file has been moved. An example: <?php /* When a file which has been called by file_exist has been moved, the file_exist next call gives true again */ $f = "foo.txt"; file_put_contents( $f, "content" ); if(file_exists( $f )){ rename( $f, $f.".moved" ); } if( file_exists( $f )){ echo "Wrong! the file has just been moved! file_exists should return false."; rename( $f, $f.".willnotwork" ); //It gives a warning } ?> The same code tested in PHP 5.2.4-2ubuntu5.6 with Suhosin-Patch 0.9.6.2 (cli) behaves correctly. ---- Server IP: 80.64.47.13 Probable Submitter: 80.174.184.72 ---- Manual Page -- http://www.php.net/manual/en/function.file-exists.php Edit -- https://master.php.net/note/edit/91008 Del: integrated -- https://master.php.net/note/delete/91008/integrated Del: useless -- https://master.php.net/note/delete/91008/useless Del: bad code -- https://master.php.net/note/delete/91008/bad+code Del: spam -- https://master.php.net/note/delete/91008/spam Del: non-english -- https://master.php.net/note/delete/91008/non-english Del: in docs -- https://master.php.net/note/delete/91008/in+docs Del: other reasons-- https://master.php.net/note/delete/91008 Reject -- https://master.php.net/note/reject/91008 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#155807) next »