Web Hosting Talk







View Full Version : file_get_contents


wayiran
08-18-2006, 01:49 PM
I'm using this code:
if (!(file_get_contents($linkaddress)==false)){
}
and getting this error:
Warning: file_get_contents(http://www.yahoo.comhttp://www.yahoo.com) [function.file-get-contents (http://localhost/function.file-get-contents)]: failed to open stream: No error in C:\wamp\www\web.php on line 58
But I want instead of giving error, it returns false, so that it doesnt execute if.
I searched in php manual, overthere it was written if the address does not exist(like my example: http://www.yahoo.comhttp://www.yahoo.com) It will return "false", but why I'm getting error?

php manual:

Identical to file() (mk:@MSITStore:D:\php_manual_en.chm::/en/function.file.html), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

maxymizer
08-18-2006, 02:10 PM
Use if(!@file_get_contents()) (@ is to surpress warning message). Also, you probably noticed that your URL is in the wrong format, hence the error..

wayiran
08-18-2006, 02:54 PM
thanks, i fixed it.