How do I check if a URI exists with PHP?
I guess it will return an error code and I can check it before I use
file_get_contents, because if I use
file_get_contents on a link that doesn't exist, it gives me an error.
try the function
array get_headers($url, [, int $format = 0 ]), it should return
false on failure - otherwise, you can assume the uri exists, since the web server provided you with header info.
I hope the function uses an HTTP HEAD request as opposed to a GET, which should result in a lot less traffic than in the
fopen solutions above.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki