Sometimes we need to check whether a remote files exist or not? Most of the time we need it for remote image. We can do it very easily in PHP (v >=5.3.0 ), here is the sample code.
$file_headers = @get_headers( 'http://example.com/image.jpg' );
if( strpos( $file_headers[0], ' OK' ) !== false ){
// THE IMAGE CAN BE ACCESSED.
}else{
// THE IMAGE CANNOT BE ACCESSED.
}