PHP rename() function and examples


 

PHP rename() function and examples

In this part of the tutorial we will learn about the function rename() in context of file handling. And also we will see the example related to the rename() function

In this part of the tutorial we will learn about the function rename() in context of file handling. And also we will see the example related to the rename() function

Syntax of PHP rename() Function

bool rename(file_name,new_name[,context])

  • rename() function changes the name(renames)of the given file or the directory

Example of PHP rename() Function

Code for PHP rename() Function

<?php
    a
=rename("aa.txt","aaaaa.txt");
    if
($a)
      echo
"file renamed";
    else
      echo
"file renaming failure ";
?>

Output
file renamed

Ads