What are the potential pitfalls of naming a text file with an image file extension like .jpg.txt?

Naming a text file with an image file extension like .jpg.txt can cause confusion for both users and applications trying to open the file. To avoid this issue, it is recommended to use the correct file extension that accurately reflects the file type. If you need to store additional information about the file, consider using a separate metadata file or embedding the information within the file itself.

// Example of renaming a text file with an image file extension
$oldFileName = 'textfile.jpg.txt';
$newFileName = 'textfile.txt';

if (rename($oldFileName, $newFileName)) {
    echo 'File renamed successfully.';
} else {
    echo 'Error renaming file.';
}