What are the best practices for handling file names with spaces in PHP file existence checks?

When handling file names with spaces in PHP file existence checks, it is important to properly handle the spaces to ensure accurate results. One common approach is to use the `urlencode()` function to encode the file name before performing the existence check. This will ensure that the file name is correctly interpreted by PHP and the file existence check will work as expected.

$filename = "file with spaces.txt";
$encoded_filename = urlencode($filename);

if (file_exists($encoded_filename)) {
    echo "File exists!";
} else {
    echo "File does not exist.";
}