Url_exists

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Url_exists

AlternativeNick
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; };
};

Reply

Avalon
QUOTE(AlternativeNick @ Feb 3 2007, 04:52 AM) *
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"?

 

 

 


Reply

QuickSilva
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).

Reply

galexcd
QUOTE(Avalon @ Feb 3 2007, 03:31 AM) *
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

QUOTE(QuickSilva @ Feb 3 2007, 04:05 AM) *
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

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. url_exists() php - 48.63 hr back. (1)
  2. url_exists "php" - 58.46 hr back. (1)
  3. function url_exists ($url) - 162.58 hr back. (1)
  4. url_exists in php - 238.41 hr back. (1)
  5. url_exists( - 498.49 hr back. (1)
  6. function url_exists - 147.35 hr back. (2)
  7. url_exists php - 239.45 hr back. (4)
  8. free php host "fsockopen" "500mb" - 677.46 hr back. (1)
  9. php url_exists - 718.41 hr back. (1)
  10. php fonction url_exists - 723.14 hr back. (1)
  11. fsockopen always true - 1116.87 hr back. (1)
  12. using function url_exists php - 1118.54 hr back. (1)
  13. url_exists - 68.44 hr back. (17)
  14. php url_exists - 127.54 hr back. (18)
Similar Topics

Keywords : url, exists

  1. Google Tv Exists And How To Invite Yourself!
    (9)
  2. Let Us Say Paradise Exists!
    would you want to die? (13)
    If there was(or is) a paradise which you came to after you die. Would you want to die? I would. Why
    have good and bad moments on earth when you can have only good time in paradise. Why be here and get
    knowledge from school and waste so many years when you could get all the knowledge you wanted in one
    second in paradise? Wouldn't that be better?....
  3. Soldier Gets 100 Years In Prison For Raping An Iraqi Girl
    Sgt. Paul Cortez, is sentenced. Justice exists after all. (28)
    Soldier gets 100 years in prison for raping an iraqi girl Source:
    http://www.latimes.com/news/nationworld/na...eadlines-nation Justice exists after all! At
    least sometimes i mean. This peace of crap of sargent raped a young iraqi girl and murdered her
    family just for fun, just for nothing. 100 years sentence to this thing called "Paul Cortez" is
    nothing, i do not know how he could live after doing that, i mean, anyone that rapes a girl or a
    woman must not live, that is just my opinion on this case and on the matter of death sentences.
    What do you think? Do y....
  4. In Spain Exists Pages Like Www.opineygane.com
    (0)
    You receive in your e-mail surveys. Then you fill up the surveys and they pay to you.....

    1. Looking for url, exists

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for url, exists

*MORE FROM TRAP17.COM*
advertisement



Url_exists



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE