Is it possible to accurately determine the file type based on the client's default program settings in PHP?

It is not possible to accurately determine the file type based on the client's default program settings in PHP. The file extension or MIME type should be used to determine the file type instead.

// Example of checking file extension to determine file type
$filename = "example.txt";
$file_extension = pathinfo($filename, PATHINFO_EXTENSION);

switch ($file_extension) {
    case "txt":
        echo "Text file";
        break;
    case "jpg":
    case "jpeg":
        echo "JPEG image";
        break;
    case "pdf":
        echo "PDF document";
        break;
    default:
        echo "Unknown file type";
}