How can I use the rename function to rename a file or directory in PHP? Example code: - Biz Tech

How can I use the rename function to rename a file or directory in PHP? Example code:

Listen
$file = "/path/to/file.txt";
$new_name = "/path/to/new_name.txt";

rename($file, $new_name);