To move a directory in PHP, you can use the rename()
function. The rename()
function can be used to rename or move a file or directory.
Here is an example code snippet that shows how to move a directory in PHP:
main.php273 chars13 lines
In the above example, we first check if the old directory exists using the is_dir()
function. If the old directory exists, we then use rename()
function to move it to the new directory. Finally, we display a message to the user to confirm that the directory was moved successfully.
Note that the rename()
function can also be used to rename a directory by providing a new name in place of the new directory path.
gistlibby LogSnag