You've spent a great deal of time and money to set up and configure your PHP website just right. Now, for some reason, you need to copy it to another web server or to a different folder on your current web server. You have several different options for how to do this. Use a PHP script to copy the file to another location. You just need to create the script, load it to your web server and run it. All of the files on your site will be copied to the new destination.
Open a text editing (Notepad) or web authoring application on your computer. Click on "File" and then "New" to create a new file. There also may be a "New" icon on the toolbar.
Type in the following PHP code to copy files from one location to another:
"bool copy (string $source, string $dest [, resource $context])"
Leave out the quotation marks when typing the code. Change "source" to the file location of the PHP file that you want to move. Change "dest" to the destination location to where you are moving the PHP file to.
Type in the whole script to copy all of the files on your web server to another location. To save some time when you have a lot of files, use the following script to copy the entire public_html directory to another location:
Omit the quotation marks at the beginning and end of the code. Save the file as a PHP file and upload it into your public_html folder on your web server. Run the script by typing in the file location in the address bar of a web server. Input the destination you want the files copied to and then allow the script to do its job.
This script only copies the PHP files and not the database behind the site. You will need to export all of the data from your database and input it into a new database on the new server for it to work. Go to the MyPHPAdmin application on your CPanel (the web hosting management tool that came with your hosting account), select the database you want to copy and click on "Export." The database will be exported as a CSV file.