如何在PHP脚本中运行url并获得响应?

I have set of records like this,

-------------------------------------------------
id_detail  |        id_url          |  id_name  |
-------------------------------------------------
   43454   |  xyz.com/xxx/yyyy.jpg  |   yyyyy   |
   43674   |  xyz.com/zzzz/ddd.jpg  |   rrrr    |
   48884   |  xyz.com/aaaa/eee.jpg  |   mmmm    |
   ....
   ....
   49994   |  xyz.com/cccc/fff.jpg  |   uuuu    |
-------------------------------------------------

now i need to run this url in while loop and if the images loads then i have to store respose as NO & if url resturn 404 then i have to store YES. Could anyone help me on it ? Please tell me how to get run url in php or curl and get response.

Sorry if my question was basic, i tried to get some idea on google but couldn't find so posting here. Thanks in advance

you can use curl and because of your condition you must get http header with curl_setopt($ch, CURLOPT_HEADER, true); and if you don't need image you can prevent to get body with curl_setopt($ch, CURLOPT_NOBODY, true);. after set this option you get response like :

HTTP/1.1 200 OK Date: Thu, 29 Sep 2016 15:17:34 GMT Server: Apache Last-Modified: Sun, 15 Nov 2015 06:45:21 GMT Accept-Ranges: bytes Content-Length: 50822 Content-Type: image/png Age: 423 Expires: Wed, 05 Oct 2016 06:06:51 GMT 

if status code is 200 like above its exist but if status code 404 its not exist.

the final code something like this:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"xyz.com/xxx/yyyy.jpg");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);
curl_close ($ch);
echo $server_output;

you must read first character of a $server_output ('HTTP/1.1 200 OK' = exist) or ('HTTP/1.1 404 Not Found' = not exist)