How does URL encoding affect the handling of spaces in file names in PHP?
URL encoding replaces spaces in file names with "%20" to ensure compatibility with URLs. In PHP, when handling file names with spaces, it's important to use urlencode() to encode the file name before using it in a URL. This ensures that the spaces are properly encoded and can be handled correctly by the server.
$filename = "my file.txt";
$encoded_filename = urlencode($filename);
echo "<a href='download.php?file=$encoded_filename'>Download File</a>";