How does the file_exists() function handle case sensitivity in file names on different operating systems?

The file_exists() function in PHP handles case sensitivity in file names differently depending on the underlying operating system. For example, on Windows, file names are not case-sensitive, while on Unix-based systems like Linux, file names are case-sensitive. To ensure consistent behavior across different operating systems, you can normalize the file path to a consistent case before checking its existence using the file_exists() function.

$file_path = 'path/to/your/file.txt';
$file_path = realpath($file_path); // Normalize file path
if(file_exists($file_path)){
    echo "File exists!";
} else {
    echo "File does not exist.";
}