Exception handling with get_meta_tags() & get_headers()?
问题 In PHP, I am using get_meta_tags() and get_headers() , however, when there is a 404, those two functions throw a warning. Is there any way for me to catch it? Thanks! 回答1: get_headers does not throw a Warning/Error on 404, but get_meta_tags does. So you can check the header response and do something, when it's not OK: $url = 'http://www.example.com/'; $headers = array(); $metatags = array(); $validhost = filter_var(gethostbyname(parse_url($url,PHP_URL_HOST)), FILTER_VALIDATE_IP); if(