Re: file_exists, Windows, and EasyPHP
| From: | Jim Lucas | Date: | Mon, 18 Jun 2007 21:23:33 +0000 |
| Subject: | Re: file_exists, Windows, and EasyPHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257337@lists.php.net to get a copy of this message | ||
Myron Turner wrote:
I've written a plugin for DokuWiki which uses the following DokuWiki function for reading files: function io_readFile($file,$clean=true){First off, don't jack someone else's thread. Secondly, I think it might have something to do with the space in the file name. Try changing all spaces to %20 and see what happens. $string = str_replace(' ', '%20', $string); should do the trick -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare$ret = ''; if(@file_exists($file)){ if(substr($file,-3) == '.gz'){ $ret = join('',gzfile($file)); }else if(substr($file,-4) == '.bz2'){ $ret = bzfile($file); }else{ $ret = join('',file($file)); } } if($clean){ return cleanText($ret); }else{ return $ret; }} On Linux machines, this seems to behave as you would hope, that is, if the file doesn't exist then you get back a null string. In any event, none of the users who have installed it on Linux machines have had a problem with it. And I have done several installs myself. But one user installed the plugin on a Windows machine and the code fell through to $ret = join('',file($file)) even though there was no $file. The result was an error message:Permission denied in *E:\Program Files\EasyPHP 2.0b1\www\dokuwiki\inc\io.php* on line *97*Line 97 is the join. So the function is attempting to read a non-existent file. I was just wondering whether there is some difference in the way his PHP version handles the @ operator in:if(@file_exists($file))That is, is it possible that by suppressing errors, this expression somehow returns true? And is it a bug? Thanks. Myron