In this tutorial we’ll learn how to run PHP program on local pc. For this purpose, You must have PHP environment installed on your pc.

If you don’t have PHP installed and running on your pc. Just visit the following links

Write your first PHP program

Create a file hello.php in root directory of your web server. If you are using XAMPP , root directory is "C:\xampp\htdocs" and in Ubuntu root directory is /var/www/html/ . Write the following code in hello.php

    echo "Hello world";

For writing code you can you any code editor you like. I recommend using Visual Studio Code , which I use most of the time.

Running first PHP progran

When you’ve written the code , you need a browser to see the result. Now , open your bowser and go to http://localhost/hello.php . You will see something like this on the browser.

Hello world PHP


We created a file with .php extension . Files with .php extension are processed and showed in the browser. Generally echo statement shows a string to the output. Here the string is "Hello world".

That’s really simple. Isn’t it ? Feel free to comment if you got any troubles.