Bug #12033 Updated: file_exists doesn't work properly with variables

From: Date: Wed, 11 Jul 2001 20:58:42 +0000
Subject: Bug #12033 Updated: file_exists doesn't work properly with variables
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-59752@lists.php.net to get a copy of this message
ID: 12033 Updated by: zak Reported By: ddruff@gemini1consulting.com Old Summary: file_exists doesn't work properly with variables Old Status: Status: Bogus Bug Type: Any Operating System: Win 95 PHP Version: 4.0.5 New Comment: The result of the call to file_exists() is cached. To clear the cache, call clearstatcache() before your second call to file_exists() If this does not fix the problem, please reopen the bug. :) Previous Comments: ------------------------------------------------------------------------ [2001-07-11 14:50:07] ddruff@gemini1consulting.com The example in my previous submission did not show the apparent bug. The example script did not match exactly what was going on in my actual script. The problem seems to only occur when two file_exists statements are used in a row and the path argument used uses the same "slash style" (forward or backward) each time. An example demonstrating the problem be dowloaded here: ftp://www.gemini1consulting.com/pub/tekhelp/test_file_exists.phps (You will need to change the extension to php for it to work). ------------------------------------------------------------------------ [2001-07-11 03:07:11] zak@php.net I cannot reproduce this under Windows 2000 with PHP 4.0.6 Do you get the same error if you use a literal value instead of a variable. ie. var_dump (file_exists ("c:/some_random_file_name")); or var_dump (file_exists ("c:\\some_random_file_name")); ------------------------------------------------------------------------ [2001-07-11 01:00:59] ddruff@gemini1consulting.com The following won't work in Win95: $path="c:/test.bat"; if(file_exists($path)) {print "file $path exists"} This will report a file existing even though it doesn't. You might think that this is because we are using forwardslashes in windows BUT IF you then parse $path to replace the forwardslashes with backslashes (using a regular expression) it still doesn't work. BUT if you do this: $path="\"".$path."\""; (leaving $path with forward slashes) it does work properly. I suppose this is a bug? ------------------------------------------------------------------------ ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=12033&edit=1

« previous php.dev (#59752) next »