Moving Files in PHP

The function rename also allows moving files. To do this, the second parameter of the function needs to specify the new path to the file. Let's move our file to the dir folder as an example, while renaming it to new.txt:

php<?php
  rename('test.txt', 'dir/new.txt');
?>

You can perform only the move without renaming the file itself:

php<?php
  rename('test.txt', 'dir/test.txt');
?>
Задание 1

Let there be a file file.txt in the root of your site. Also, let there be a folder dir in the root of your site. Move the file to this folder.

Задание 2

Let there be a folder dir1 in the root of your site, and a file file.txt inside it. Also, let there be a folder dir2 in the root of your site. Move the file to this folder.