How do I test PHP files in WordPress?

The WordPress Codex documentation on Installing WordPress and Editing Files give you pretty much all information you need.

You will need a web server to test the code and changes. So you can either do this on your web server (assuming you have some sort of hosting package, because you mention ‘upload’), or on your local machine. For easy setup, there is XAMPP or WampServer on Windows, or MAMP for Macs and LAMP for Linux based machines (and many, many more).

Basically, there is no right or wrong way to do this, as long as it works for you. Some people will never edit a single file on a live website, simply because they fear things will break on the live website version. That’s why they always test changes on a local web server (using one of the previously mentioned packages). But if you’re only making small changes in CSS for example and just starting out, there is no harm in experimenting a bit in the live install. 🙂

Good rule of thumb: Make backups before you do anything, so if you run into any trouble, you always have a backup of the original files to restore.