Don't send any output via "echo" or similar because you can't redirect AFTER you've already started sending out the page.
file_get_contents will return false when it can't complete the request so make sure you check for that before attempting to use the returned variable and assuming you actually have some html to work with.
Additionally you have to exit after your redirect to prevent the rest of the code being processed.
$html = file_get_html($website);
if($html === false) {
header('Location: https://test.com/login/display/error_message.php');
exit;
}
// You can now work with $html string from here onwards.