Download the contents of a URL in PHP even if it returns a 404

前端 未结 4 1026
半阙折子戏
半阙折子戏 2020-12-05 11:06

I want to download the contents of a URL using PHP, even if the HTTP response code is 404. file_get_contents will error out, and I wasn\'t able to find an answe

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 11:54

    Use cURL instead. It allows much greater control, and will let you read any content retrieved and the status code.

提交回复
热议问题