How can I check if a URL exists via PHP?

前端 未结 22 1652
天涯浪人
天涯浪人 2020-11-22 04:13

How do I check if a URL exists (not 404) in PHP?

22条回答
  •  一生所求
    2020-11-22 05:14

    $headers = @get_headers($this->_value);
    if(strpos($headers[0],'200')===false)return false;
    

    so anytime you contact a website and get something else than 200 ok it will work

提交回复
热议问题