PHP Unlink

Hi - I’m quite new to PHP (and this is my first post)

I wanted to know why this doesn’t work:
I’m getting variables from the URL:
/Operation.php?file=Data.txt&op=delete

(Data.txt is in the same directory)

This is my code:

$file2 = $_GET['file'];
$op2 = $_GET['op'];

function deletefile()
  {
 unlink($file2);
  }
  
  if ($op2 = "delete")
  {
 echo $file2;
 deletefile();
  }

And this is the error I get:
Warning: unlink(): No such file or directory in /home/…/Singh/Operation.php on line **15

**The echo $file2 produces Data.txt
What’s my problem? :puzzled: