简体   繁体   中英

PHP Wamp is not finding a file which exists

I'm having a critical issue where my WAMP installation for PHP 5.3.0 is not finding a file which exists within my computer. Does anyone know anything about this? Possibly a PHP Bug? Any help would be much appreciated.

Here is the variable which creates the file:

$baseNewsUrl = "C:/reviews/reviews/$platform/$fullname";

And here is the code which grabs the contents:

if(is_file($baseNewsUrl)){
    $contents = file_get_contents($baseNewsUrl);
} else {
    echo "File not found. " . "\r\n";
    continue;
}   

Here is the output of $baseNewsUrl : C:/reviews/reviews/GBA/r20107_GBA.htm And the file does exist.

Check that the entire path leading up to your file is readable by the user PHP is running as (if you are using IIS, this might be something like "Network Service," although I am not particularly experienced with PHP on Windows). Also, check whether the INI directives "open_basedir" or perhaps "safe_mode" are set--these would give PHP self-imposed limits on which files are accessible.

Do a var_dump (not an echo) on your variable.

var_dump($baseNewsUrl);

and look at the actual contents. You may have some invisible garbage characters in there that's preventing Windows if you're doing this in a browser to make sure there's no empty tags (or other browser-render-invisible) characters.

If that doesn't reveal anything, remove the is_file check and try to open the file with file_get_contents (or any file related function) and var_dump it's contents. You'll either open the file, or PHP will spit out an error/warning/notice (either to your browser or to your error log) that should let you know why it can't open the file.

I'm gonna say this, and it very well might not be your problem but it is a recurring one for me. If you use skype on your computer, it has a somewhat known compatibility issue with WAMP. It cause's WAMP to be unstable, not load files properly.. everything.

这是由于Windows Vista和WAMP。

在窗户上

$baseNewsUrl = "C:\\reviews\\reviews\\$platform\\$fullname";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM