How do I check if a URL exists (not 404) in PHP?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Here is a solution that reads only the first byte of source code... returning false if the file_get_contents fails... This will also work for remote files like images.
Other way to check if a URL is valid or not can be:
cURL can return HTTP code I don’t think all that extra code is necessary?
you cannot use curl in certain servers u can use this code
pretty fast: