How to validate URL?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Con

    How to validate URL?

    Hi, is there a method with PEAR that would allow one to properly
    validate a URL?

    Thanks in advance,

    -Conrad

  • Markku Uttula

    #2
    Re: How to validate URL?

    Con wrote:[color=blue]
    > Hi, is there a method with PEAR that would allow one to properly
    > validate a URL?[/color]

    Syntactically correct URL can quite easily be invalid. The only way to
    validate URL is to connect to it and see if it can be retrieved.

    --
    Markku Uttula


    Comment

    • Peter Albertsson

      #3
      Re: How to validate URL?

      There is the Net_URL class.

      Maybe something like this could do it:

      I wouldn't trust this to be working 100% correctly at all times though...

      $urlObj = Net_URL($url_st r);
      if ($url_str == $urlObj->getURL()) {
      // Valid URL
      } else {
      // Not valid URL
      }

      Best Regards,

      Peter Albertsson




      "Con" <conradwt@runbo x.com> wrote in message
      news:1111547064 .549878.274230@ f14g2000cwb.goo glegroups.com.. .[color=blue]
      > Hi, is there a method with PEAR that would allow one to properly
      > validate a URL?
      >
      > Thanks in advance,
      >
      > -Conrad
      >[/color]


      Comment

      Working...