|
|
|
|
![]() ![]() |
Feb 2 2007, 05:52 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 210 Joined: 7-June 06 Member No.: 24,817 |
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. CODE function url_exists($url){
if(!strstr($url, "http://")) { $url = "http://".$url; }; $fp = @fsockopen($url, 80); if($fp === false) { return 'false'; } else { return true; }; }; This post has been edited by AlternativeNick: Feb 2 2007, 05:53 PM |
|
|
|
Feb 3 2007, 11:31 AM
Post
#2
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 630 Joined: 12-August 05 From: Melbourne, Australia Member No.: 10,624 |
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. CODE 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"? |
|
|
|
Feb 3 2007, 12:05 PM
Post
#3
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 181 Joined: 15-January 07 From: Rotherham, UK Member No.: 37,245 |
CODE 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: CODE 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). |
|
|
|
Feb 3 2007, 10:22 PM
Post
#4
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 1,069 Joined: 25-September 05 From: L.A. Member No.: 12,251 |
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 way And 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 true if(false===0)//returns false |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 7th October 2008 - 12:24 AM |