What modifications can be made to the script provided to ensure that is_dir and is_file functions work correctly when accessing files on Windows shares in PHP?

The issue with using is_dir and is_file functions on Windows shares in PHP is that they may not work correctly due to the way Windows handles file paths. To ensure these functions work correctly, you can modify the script to use the realpath function to resolve the file path to its absolute form before checking if it is a directory or a file.

$file_path = '\\\\server\\share\\file.txt';
$real_path = realpath($file_path);

if ($real_path && is_dir($real_path)) {
    echo 'The path is a directory.';
} elseif ($real_path && is_file($real_path)) {
    echo 'The path is a file.';
} else {
    echo 'The path is not a valid directory or file.';
}