How can PHP be used to rename a file, such as changing "bild.jpg" to "bild2.jpg"?

To rename a file in PHP, you can use the `rename()` function. This function takes two parameters: the current file name and the new file name. In this case, to change "bild.jpg" to "bild2.jpg", you would use `rename('bild.jpg', 'bild2.jpg')`.

<?php
$old_name = 'bild.jpg';
$new_name = 'bild2.jpg';

if (rename($old_name, $new_name)) {
    echo "File renamed successfully.";
} else {
    echo "Error renaming file.";
}
?>