AlternativeNick 0 Report post Posted February 2, 2007 (edited) i found this on php.net, and it worked for a little while, and now it doesnt work.i changed some of it trying to fix it, but it always returns false. function url_exists($url){ if(!strstr($url, "http://")) { $url = "http://".$url; }; $fp = @fsockopen($url, 80); if($fp === false) { return 'false'; } else { return true; };}; Edited February 2, 2007 by AlternativeNick (see edit history) Share this post Link to post Share on other sites
Avalon 1 Report post Posted February 3, 2007 i found this on php.net, and it worked for a little while, and now it doesnt work.i changed some of it trying to fix it, but it always returns false. function url_exists($url){ if(!strstr($url, "http://")) { $url = "http://".$url; }; $fp = @fsockopen($url, 80); if($fp === false) { return 'false'; } else { return true; };}; I'm not sure, but perhaps the last line of code with the "$fp === false" is the problem. Shouldn't that be "$fp == false"? Share this post Link to post Share on other sites
QuickSilva 0 Report post Posted February 3, 2007 function url_exists($url){if(!strstr($url, "http://")) { $url = "http://".$url; };$fp = @fsockopen($url, 80);if($fp === false) { return 'false'; } else { return true; };};Right here goes. You are returning the text "false" and not just false, so that's problem one. Another problem I spotted was that you put a ";" after the "}", and you do not do that. So here is the code fixed:function url_exists($url){if(!strstr($url, "http://")) { $url = "http://".$url; }$fp = @fsockopen($url, 80);if($fp === false) { return false; } else { return true; }} And I believe it isn't to do with the ===, as that means if it returns something (I think). Share this post Link to post Share on other sites
galexcd 0 Report post Posted February 3, 2007 I'm not sure, but perhaps the last line of code with the "$fp === false" is the problem. Shouldn't that be "$fp == false"?Should still work the same wayAnd I believe it isn't to do with the ===, as that means if it returns something (I think).'===' means exact equivalence instead of just equivalence. Example:if(false==0)//returns trueif(false===0)//returns false Share this post Link to post Share on other sites