checking for broken URLs with PHP?

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

    #1

    checking for broken URLs with PHP?

    Hi,

    Can anyone tell me how to connect to a URL using PHP for the purpose
    of obtaining the HTTP response code? Specifically, I want to be able
    to ascertain whether a link is down (404) or alive.

    A bare-bones example would be appreciated.

    Thanks!

  • Captain Paralytic

    #2
    Re: checking for broken URLs with PHP?

    On 13 Nov, 11:00, AK <danr...@gmail. comwrote:
    Hi,
    >
    Can anyone tell me how to connect to a URL using PHP for the purpose
    of obtaining the HTTP response code? Specifically, I want to be able
    to ascertain whether a link is down (404) or alive.
    >
    A bare-bones example would be appreciated.
    >
    Thanks!
    Try typing
    php http request
    into Google

    Comment

    • igrosny@gmail.com

      #3
      Re: checking for broken URLs with PHP?

      On Nov 13, 8:00 am, AK <danr...@gmail. comwrote:
      Hi,
      >
      Can anyone tell me how to connect to a URL using PHP for the purpose
      of obtaining the HTTP response code? Specifically, I want to be able
      to ascertain whether a link is down (404) or alive.
      >
      A bare-bones example would be appreciated.
      >
      Thanks!
      Perhaps this could help



      Comment

      • Csaba Gabor

        #4
        Re: checking for broken URLs with PHP?

        On Nov 13, 12:00 pm, AK <danr...@gmail. comwrote:
        ....
        Can anyone tell me how to connect to a URL using PHP for the purpose
        of obtaining the HTTP response code? Specifically, I want to be able
        to ascertain whether a link is down (404) or alive.
        >
        A bare-bones example would be appreciated.
        <?php
        file_get_conten ts("http://google.com");
        var_dump($http_ response_header );
        ?>


        Csaba Gabor from Vienna

        Comment

        • AK

          #5
          Re: checking for broken URLs with PHP?

          On Nov 14, 12:09 am, Csaba Gabor <dans...@gmail. comwrote:
          On Nov 13, 12:00 pm, AK <danr...@gmail. comwrote:
          ...
          >
          Can anyone tell me how to connect to a URL using PHP for the purpose
          of obtaining the HTTP response code? Specifically, I want to be able
          to ascertain whether a link is down (404) or alive.
          >
          A bare-bones example would be appreciated.
          >
          <?php
          file_get_conten ts("http://google.com");
          var_dump($http_ response_header );
          ?>
          >
          Csaba Gabor from Vienna
          Thanks, that's the sort of "quick solution" I was looking for
          (although I managed to find it myself after a bit of digging:
          $arr = get_headers("ht tp://www.google.com" );
          is even more concise)

          Thanks to the previous responses as well, including the one that
          suggested using a quaint little thing that seems to have the amazing
          ability to search through web pages! (Google, I think it's called... )

          Cheers

          Comment

          • Lars Eighner

            #6
            Re: checking for broken URLs with PHP?

            In our last episode,
            <1194951649.555 713.91490@k79g2 000hse.googlegr oups.com>,
            the lovely and talented AK
            broadcast on comp.lang.php:
            Hi,
            Can anyone tell me how to connect to a URL using PHP for the purpose
            of obtaining the HTTP response code? Specifically, I want to be able
            to ascertain whether a link is down (404) or alive.
            A bare-bones example would be appreciated.
            Thanks!
            Is there some reason searching the manual index on 'http' did not turn up
            http_head for you?

            --
            Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
            Countdown: 432 days to go.
            What do you do when you're debranded?

            Comment

            Working...