Home  >  Article  >  Backend Development  >  What to do if php rename error occurs

What to do if php rename error occurs

PHPz
PHPzOriginal
2020-09-25 15:45:493101browse

php rename error is due to an error in the path. The solution is: first check whether the file "before.txt" exists or whether the path is written incorrectly; then modify the correct path.

What to do if php rename error occurs

Recommended: "PHP Video Tutorial"

php rename() failure problem

Code :

$before = '/Applications/MAMP/htdocs/www/store/data/log/ before.txt';
$after = '/Applications/MAMP/htdocs/www/store/data/log/' . 'after.txt';
if (rename($before, $after)) {
echo "换名成功";
}else{
echo "换名失败";
}

Error message: The return value is always false and the name change failed. . .

Solution:

  • Check whether the file before.txt exists or whether the path is written incorrectly

  • The reason is The path is wrong'/Applications/MAMP/htdocs/www/store/data/log/"There is an extra space here" before.txt'

The above is the detailed content of What to do if php rename error occurs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn