the easiest way is to make sure you save the file in a *.php format.
If you go to your browser and type in localhost in the address bar it should bring you up to a php configuration page, if you scroll down the page you should find a line that says document_root. (on mine, it's apache/htdocs). Save your php file in that directory
to view it, simply type in localhost/file.php in the address bar of your browser. Hope that works for you
Jason