PHP中如果fopen指向的文件不存在时怎么显示或跳转指定的其他内容或链接

index.php代码如下

<?php
$id = $_GET['id'];
$fh = fopen('http://abc.com/'.$id.'.txt', 'r');
if($mb){
while(!feof($mb)) {
echo fgets($mb);
}
}
?>

访问链接http://abc.com/?id=xx

访问时如果xx不存在显示的是报错:

Warning: fopen(http://abc.com/xx.txt): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /www/wwwroot/abc.com/index.php on line 3

怎么弄成如果xx不存在显示指定内容,比如显示404页或跳转到指定url?

file_exists
https://www.cnblogs.com/jcydd/p/10943772.html