What are some best practices for efficiently renaming files in PHP without causing server performance issues?

When renaming files in PHP, it is important to do so efficiently to avoid causing server performance issues. One best practice is to use the `rename()` function, which is a built-in PHP function specifically designed for renaming files. Additionally, it is recommended to check if the file exists before attempting to rename it to avoid errors.

$oldFileName = 'old_file.txt';
$newFileName = 'new_file.txt';

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