How can one determine the file type and content of files accessed via FTP, especially when unsure if they are PHP or HTML files?

To determine the file type and content of files accessed via FTP, you can use the PHP function `finfo_file()` to get the MIME type of the file. This will help you identify if the file is a PHP or HTML file. You can then read the content of the file using `file_get_contents()` function to further analyze its content.

$filename = 'sample_file.php'; // Replace with the actual filename
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$file_type = finfo_file($finfo, $filename);

if($file_type == 'text/html') {
    echo "This is an HTML file.";
    $content = file_get_contents($filename);
    echo $content;
} elseif($file_type == 'text/x-php') {
    echo "This is a PHP file.";
    $content = file_get_contents($filename);
    echo $content;
} else {
    echo "Unknown file type.";
}

finfo_close($finfo);