poddys Posted July 23, 2010 Share Posted July 23, 2010 I want to be able to check if a local copy of a website exists on a pc, and thought I might be able to do this by checking for the existance of a file on localhost. I tried this using both localhost and 127.0.0.1 but it does not find the file I told it to look for. Is it possible, or am I missing something? Thanks $offline_locn = "http://localhost/QAOfflineVersion.txt"; if( file_exists('$offline_locn')) { $offline_system = "Y"; echo('Offline System Installed $offline_locn'); } else { $offline_system = "N"; echo("Offline System Not-Installed $offline_locn"); } Link to comment https://forums.phpfreaks.com/topic/208680-checking-existance-of-a-localhost-file/ Share on other sites More sharing options...
Pikachu2000 Posted July 23, 2010 Share Posted July 23, 2010 What does that script return as an echo when run? I suspect the single quotes should be eliminated in the file_exists() function and changed to double quotes in the echos. Link to comment https://forums.phpfreaks.com/topic/208680-checking-existance-of-a-localhost-file/#findComment-1090212 Share on other sites More sharing options...
jdavidbakr Posted July 23, 2010 Share Posted July 23, 2010 Yes, single quotes won't expand your variable. Try changing it to if( file_exists($offline_locn)) Link to comment https://forums.phpfreaks.com/topic/208680-checking-existance-of-a-localhost-file/#findComment-1090214 Share on other sites More sharing options...
poddys Posted July 23, 2010 Author Share Posted July 23, 2010 I tried changing the quotes but it made no difference. I am assuming that if the test is being run on a remote server (in this case our iSeries), that I can refer to localhost ok, to link to the system on the pc? Just about to head home for the weekend. Will pick this up Monday morning. Really appreciate the help Tony PS: Have a great weekend. Link to comment https://forums.phpfreaks.com/topic/208680-checking-existance-of-a-localhost-file/#findComment-1090216 Share on other sites More sharing options...
jdavidbakr Posted July 23, 2010 Share Posted July 23, 2010 localhost will be the server where the script is executing - are you trying to look on the client PC? You can't do that. Link to comment https://forums.phpfreaks.com/topic/208680-checking-existance-of-a-localhost-file/#findComment-1090217 Share on other sites More sharing options...
Pikachu2000 Posted July 23, 2010 Share Posted July 23, 2010 No. Localhost refers only to the machine on which the script is being executed. Could you describe what you're trying to do with a little more detail? Are you attempting to make a failover, or hot online standby, type of thing? Link to comment https://forums.phpfreaks.com/topic/208680-checking-existance-of-a-localhost-file/#findComment-1090221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.