1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Checking if URL Exists

Discussion in 'XenForo Development Discussions' started by James, Mar 31, 2011.

  1. James

    James Well-Known Member

    I'm trying to create a custom identity service - which I managed - however I'd like to run a check to see if the ID provided is actually a real ID.

    I can do this by resolving a URL and checking for a status code (404 - page not found) but I'm not sure how to go about it. I know I'll have to put the check in the verifyAccountName() function, but is there a function I can use apart from cURL?
  2. bambua

    bambua Well-Known Member

    You could do something like this:

    $url = "http://www.example.com/index.php";
    $header_response = get_headers($url, 1);
    if ( strpos( $header_response[0], "404" ) !== false )
      // FILE EXISTS!!
    James likes this.
  3. James

    James Well-Known Member

    I'll try that one ASAP bambua. I've found cURL to be pretty intensive and slow, I need a quick method - so yours seems a good option.

Share This Page