PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am novice PHP scripter, just coding my second one..
I am trying to open a file which is present on other server. I use is_file() fucntion to make sure if the file is present.
Problem is that, is_file() is not working for files starting with http://
I checked for path and file everything seems to be correct. Also when i try to fopen() the file removing is_file(), it works. But i need to use is_file() before opening.
well...there are several files on the server and i check if the file exits..if it does i provide a link to it on the page...thats what i am suppose to do..
$thefile = @file_get_contents('http://foo.com/whatever.html');
if($thefile === FALSE){
//the file doesn't exist (or there was some other error)
} else {
//you got the file, it's content is in $thefile
}
Yeah, there's a few ways to do it, but all of them involve you having to actually get the info from the server. You could use caching i suppose and only do a full check ever hour (or whenever) ... but it depends on the specifics of your app.