php filename.phpwhen in /var/www folder. To run the script in browser, type the url as localhost/filename.php.
If opening the file in the browser, downloads the file, instead of executing it, you need to install some packages. To do this, type the following in a terminal:
sudo apt-get install apache-mod2-php5
Now open the file again in the browser by using the url shown above, and your script should be up and running.