When using the `urlencode()` function in PHP for filenames, how does it affect the compatibility with browsers like Internet Explorer?

When using the `urlencode()` function in PHP for filenames, it can sometimes cause compatibility issues with browsers like Internet Explorer. This is because Internet Explorer does not handle special characters in URLs the same way other browsers do. To solve this issue, you can use the `rawurlencode()` function instead of `urlencode()` to encode the filenames.

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

header("Content-Disposition: attachment; filename=\"$encoded_filename\"");