What are common reasons for receiving the "Alternativ Text" instead of the image when trying to display an image using PHP?

Common reasons for receiving the "Alternative Text" instead of the image when trying to display an image using PHP include incorrect file paths, missing image files, or incorrect image file formats. To solve this issue, ensure that the file path in the code is correct, the image file exists in the specified location, and the image file format is supported.

<?php
$image_path = 'images/image.jpg';

if(file_exists($image_path)){
    $image_info = getimagesize($image_path);
    $image_type = $image_info[2];
    
    if($image_type == IMAGETYPE_JPEG || $image_type == IMAGETYPE_PNG || $image_type == IMAGETYPE_GIF){
        echo '<img src="' . $image_path . '" alt="Image">';
    } else {
        echo 'Unsupported image format.';
    }
} else {
    echo 'Image not found.';
}
?>