How do you get the HTTP status code for a remote domain in php?

后端 未结 5 1347
不思量自难忘°
不思量自难忘° 2020-12-31 23:32

I would like to create a batch script, to go through 20,000 links in a DB, and weed out all the 404s and such. How would I get the HTTP status code for a remote url?

5条回答
  •  灰色年华
    2020-12-31 23:53

    This page looks like it has a pretty good setup to download a page using either curl or fsockopen, and can get the HTTP headers using either method (which is what you want, really).

    After using that method, you'd want to check $output['info']['http_code'] to get the data you want.

    Hope that helps.

提交回复
热议问题