Home >Backend Development >PHP Problem >What to do if php rename error occurs
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.
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!