PHP Learning : How to Rename Text File in php - Publik Talk

Breaking

An informative website for every one.

Post Top Ad

Post Top Ad

Thursday, August 3, 2017

PHP Learning : How to Rename Text File in php

Description:

To rename a file you use the  rename() function.
this function also allows you to move a file to a different directory.

Code:

<?php

$myfile = './check.txt';

$newfile = './change.txt';

if(rename($myfile,$newfile))

{

echo sprintf("%s was renamed to %s",$myfile,$newfile);

}

else

{

echo 'An error occurred during renaming the file';

}

?>


Output:










No comments:

Post a Comment

Post Top Ad